diff --git a/app/javascript/core/mathFunctions.js b/app/javascript/core/mathFunctions.js index 6e93958f5..11d255228 100644 --- a/app/javascript/core/mathFunctions.js +++ b/app/javascript/core/mathFunctions.js @@ -150,19 +150,13 @@ wpd.cspline_interp = function(cs, x) { // Perform a Singular Value Decomposition (SVD) of a mxn matrix: // mat = [[...], [...], ...] (2D array, row-by-row) wpd.svd = function(mat) { - // ref: https://en.wikipedia.org/wiki/Singular-value_decomposition#Numerical_approach - let rows = mat.length; - let cols = mat[0].length; - - // Step 1: Reduce to a bidiagonal matrix using Householder reflections - - // Step 2: QR algorithm for computation of eigenvalues + let result = numeric.svd(mat); return { - U: null, - D: null, - V: null + U: result.U, + D: result.S, + V: result.V }; }; diff --git a/app/locale/de_DE/LC_MESSAGES/messages.po b/app/locale/de_DE/LC_MESSAGES/messages.po index 270b38c93..d64de4ab0 100644 --- a/app/locale/de_DE/LC_MESSAGES/messages.po +++ b/app/locale/de_DE/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-07-06 21:38-0500\n" +"POT-Creation-Date: 2018-07-10 23:12-0500\n" "PO-Revision-Date: 2017-10-24 22:43-0500\n" "Last-Translator: \n" "Language: de_DE\n" @@ -16,7 +16,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.5.3\n" +"Generated-By: Babel 2.3.4\n" #: templates/_base.html:26 msgid "Web based tool to extract numerical data from plots and graph images." @@ -24,11 +24,11 @@ msgstr "" "Web-basiertes Werkzeug zum Extrahieren von numerischen Daten aus " "Aufzeichnungen und Bildern." -#: templates/_base.html:47 +#: templates/_base.html:48 msgid "Loading application, please wait..." msgstr "Bitte warten, Anwendung wird geladen..." -#: templates/_base.html:50 +#: templates/_base.html:51 msgid "" "Problems loading? Make sure you have a recent version of Google Chrome, " "Firefox, Safari or Microsoft Edge installed." @@ -36,7 +36,7 @@ msgstr "" "Probleme beim Laden? Bitte stellen Sie sicher, dass eine akutelle Verion " "von Google Chrome, Firefox, Safari oder Microsoft Edge installiert ist." -#: templates/_base.html:72 +#: templates/_base.html:73 msgid "Fit" msgstr "passen" diff --git a/app/locale/en_US/LC_MESSAGES/messages.po b/app/locale/en_US/LC_MESSAGES/messages.po index e41766bd9..6fcfc259c 100644 --- a/app/locale/en_US/LC_MESSAGES/messages.po +++ b/app/locale/en_US/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-07-06 21:38-0500\n" +"POT-Creation-Date: 2018-07-10 23:12-0500\n" "PO-Revision-Date: 2016-12-12 23:09-0600\n" "Last-Translator: \n" "Language: en_US\n" @@ -16,23 +16,23 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.5.3\n" +"Generated-By: Babel 2.3.4\n" #: templates/_base.html:26 msgid "Web based tool to extract numerical data from plots and graph images." msgstr "" -#: templates/_base.html:47 +#: templates/_base.html:48 msgid "Loading application, please wait..." msgstr "" -#: templates/_base.html:50 +#: templates/_base.html:51 msgid "" "Problems loading? Make sure you have a recent version of Google Chrome, " "Firefox, Safari or Microsoft Edge installed." msgstr "" -#: templates/_base.html:72 +#: templates/_base.html:73 msgid "Fit" msgstr "" diff --git a/app/locale/fr_FR/LC_MESSAGES/messages.po b/app/locale/fr_FR/LC_MESSAGES/messages.po index e8949627e..1c366eedb 100644 --- a/app/locale/fr_FR/LC_MESSAGES/messages.po +++ b/app/locale/fr_FR/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-07-06 21:38-0500\n" +"POT-Creation-Date: 2018-07-10 23:12-0500\n" "PO-Revision-Date: 2017-11-01 23:56-0500\n" "Last-Translator: \n" "Language: fr_FR\n" @@ -16,7 +16,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.5.3\n" +"Generated-By: Babel 2.3.4\n" #: templates/_base.html:26 msgid "Web based tool to extract numerical data from plots and graph images." @@ -24,11 +24,11 @@ msgstr "" "Outil basé sur le Web pour extraire des données numériques à partir des " "graphes et des images graphiques." -#: templates/_base.html:47 +#: templates/_base.html:48 msgid "Loading application, please wait..." msgstr "Chargement de l'application, veuillez patienter..." -#: templates/_base.html:50 +#: templates/_base.html:51 msgid "" "Problems loading? Make sure you have a recent version of Google Chrome, " "Firefox, Safari or Microsoft Edge installed." @@ -36,7 +36,7 @@ msgstr "" "Problèmes de chargement? Assurez-vous d'avoir installé une version " "récente de Google Chrome, Firefox, Safari ou Microsoft Edge." -#: templates/_base.html:72 +#: templates/_base.html:73 msgid "Fit" msgstr "Adapter" diff --git a/app/locale/ja/LC_MESSAGES/messages.po b/app/locale/ja/LC_MESSAGES/messages.po index 1f9e506e1..bf461476a 100644 --- a/app/locale/ja/LC_MESSAGES/messages.po +++ b/app/locale/ja/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-07-06 21:38-0500\n" +"POT-Creation-Date: 2018-07-10 23:12-0500\n" "PO-Revision-Date: 2016-12-18 10:38-0600\n" "Last-Translator: \n" "Language: ja\n" @@ -16,23 +16,23 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.5.3\n" +"Generated-By: Babel 2.3.4\n" #: templates/_base.html:26 msgid "Web based tool to extract numerical data from plots and graph images." msgstr "" -#: templates/_base.html:47 +#: templates/_base.html:48 msgid "Loading application, please wait..." msgstr "" -#: templates/_base.html:50 +#: templates/_base.html:51 msgid "" "Problems loading? Make sure you have a recent version of Google Chrome, " "Firefox, Safari or Microsoft Edge installed." msgstr "" -#: templates/_base.html:72 +#: templates/_base.html:73 msgid "Fit" msgstr "" diff --git a/app/locale/messages.pot b/app/locale/messages.pot index 86645207b..6b88c5ff1 100644 --- a/app/locale/messages.pot +++ b/app/locale/messages.pot @@ -8,30 +8,30 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-07-06 21:38-0500\n" +"POT-Creation-Date: 2018-07-10 23:12-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.5.3\n" +"Generated-By: Babel 2.3.4\n" #: templates/_base.html:26 msgid "Web based tool to extract numerical data from plots and graph images." msgstr "" -#: templates/_base.html:47 +#: templates/_base.html:48 msgid "Loading application, please wait..." msgstr "" -#: templates/_base.html:50 +#: templates/_base.html:51 msgid "" "Problems loading? Make sure you have a recent version of Google Chrome, " "Firefox, Safari or Microsoft Edge installed." msgstr "" -#: templates/_base.html:72 +#: templates/_base.html:73 msgid "Fit" msgstr "" diff --git a/app/locale/ru/LC_MESSAGES/messages.po b/app/locale/ru/LC_MESSAGES/messages.po index 359b42c2c..e2aac244b 100644 --- a/app/locale/ru/LC_MESSAGES/messages.po +++ b/app/locale/ru/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-07-06 21:38-0500\n" +"POT-Creation-Date: 2018-07-10 23:12-0500\n" "PO-Revision-Date: 2016-12-18 10:38-0600\n" "Last-Translator: \n" "Language: ru\n" @@ -17,23 +17,23 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.5.3\n" +"Generated-By: Babel 2.3.4\n" #: templates/_base.html:26 msgid "Web based tool to extract numerical data from plots and graph images." msgstr "" -#: templates/_base.html:47 +#: templates/_base.html:48 msgid "Loading application, please wait..." msgstr "" -#: templates/_base.html:50 +#: templates/_base.html:51 msgid "" "Problems loading? Make sure you have a recent version of Google Chrome, " "Firefox, Safari or Microsoft Edge installed." msgstr "" -#: templates/_base.html:72 +#: templates/_base.html:73 msgid "Fit" msgstr "" diff --git a/app/locale/zh_CN/LC_MESSAGES/messages.po b/app/locale/zh_CN/LC_MESSAGES/messages.po index 7866b668d..6d5a055e8 100644 --- a/app/locale/zh_CN/LC_MESSAGES/messages.po +++ b/app/locale/zh_CN/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: WebPlotDigitizer\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-07-06 21:38-0500\n" +"POT-Creation-Date: 2018-07-10 23:12-0500\n" "PO-Revision-Date: 2018-02-21 00:47-0600\n" "Last-Translator: RGXGR \n" "Language: zh_Hans_CN\n" @@ -16,23 +16,23 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.5.3\n" +"Generated-By: Babel 2.3.4\n" #: templates/_base.html:26 msgid "Web based tool to extract numerical data from plots and graph images." msgstr "基于Web的图片数据提取工具。" -#: templates/_base.html:47 +#: templates/_base.html:48 msgid "Loading application, please wait..." msgstr "启动中,请稍等……" -#: templates/_base.html:50 +#: templates/_base.html:51 msgid "" "Problems loading? Make sure you have a recent version of Google Chrome, " "Firefox, Safari or Microsoft Edge installed." msgstr "启动错误? 确认安装了最新版本的Google Chrome,Firefox,Safari 或 Microsoft Edge。" -#: templates/_base.html:72 +#: templates/_base.html:73 msgid "Fit" msgstr "还原" diff --git a/app/templates/_base.html b/app/templates/_base.html index 6e2a3bc15..aca70ce57 100644 --- a/app/templates/_base.html +++ b/app/templates/_base.html @@ -39,6 +39,7 @@ + diff --git a/app/tests/index.html b/app/tests/index.html index 2da6f7c4e..907017873 100644 --- a/app/tests/index.html +++ b/app/tests/index.html @@ -5,6 +5,11 @@ WPD Tests + + + + + @@ -75,6 +80,7 @@ + diff --git a/app/tests/svd_tests.js b/app/tests/svd_tests.js new file mode 100644 index 000000000..845ab385d --- /dev/null +++ b/app/tests/svd_tests.js @@ -0,0 +1,26 @@ +QUnit.module("SVD tests"); +QUnit.test("SVD of 3x3 matrix", function (assert) { + + // test matrix + let mat = [ + [1, 3, 4], + [6, 9, 8], + [6, 7, 9] + ]; + + let expectedU = [[-0.25545925, -0.60219924, 0.75637071], + [-0.69818735, 0.65607252, 0.28653669], + [-0.66878622, -0.45489001, -0.58804768]]; + + let expectedD = [19.19848638, 1.66555095, 1.28220936]; + + let expectedVtranspose = [[-0.44051914, 0.36318063, -0.82100105], + [-0.61106731, 0.54866225, 0.57058434], + [-0.65767746, -0.75304022, 0.01976841]]; + + let result = wpd.svd(mat); + + assert.equal(wpdtest.matCompare(result.U, expectedU, 1e-5), true, "U"); + assert.equal(wpdtest.vecCompare(result.D, expectedD, 1e-5), true, "D"); + assert.equal(wpdtest.matCompare(result.V, expectedVtranspose, 1e-5), true, "V"); +}); \ No newline at end of file diff --git a/app/tests/testhelpers.js b/app/tests/testhelpers.js index b17528061..0fef9362c 100644 --- a/app/tests/testhelpers.js +++ b/app/tests/testhelpers.js @@ -15,3 +15,42 @@ wpdtest.fetchJSON = function(filename) { }); }); }; + +wpdtest.matCompare = function(mat1, mat2, eps) { + if(mat1 == null || mat2 == null) { + return false; + } + if (mat1.length != mat2.length) { + return false; + } + let rows = mat1.length; + let cols = mat2.length; + for (let rowIdx = 0; rowIdx < rows; rowIdx++) { + + if (mat1[rowIdx].length != mat2[rowIdx].length) { + return false; + } + + for (let colIdx = 0; colIdx < cols; colIdx++) { + if (Math.abs(mat1[rowIdx][colIdx] - mat2[rowIdx][colIdx]) > eps) { + return false; + } + } + } + return true; +}; + +wpdtest.vecCompare = function(vec1, vec2, eps) { + if (vec1 == null || vec2 == null) { + return false; + } + if (vec1.length != vec2.length) { + return false; + } + for (let vIdx = 0; vIdx < vec1.length; vIdx++) { + if (Math.abs(vec1[vIdx] - vec2[vIdx]) > eps) { + return false; + } + } + return true; +}; \ No newline at end of file diff --git a/app/thirdparty/README.md b/app/thirdparty/README.md index a6a9e854c..82d5ddaaa 100644 --- a/app/thirdparty/README.md +++ b/app/thirdparty/README.md @@ -15,3 +15,6 @@ Use the ./getThirdparty.sh script, or follow the following steps manually: - Download: https://github.com/ankitrohatgi/tarballjs/archive/master.zip - Extract to tarballjs folder +4) NumericJS: + - Download: http://www.numericjs.com/lib/numeric-1.2.6.min.js + - Extract to numericjs folder \ No newline at end of file diff --git a/app/thirdparty/getThirdparty.sh b/app/thirdparty/getThirdparty.sh index bb99cf297..799358c1e 100755 --- a/app/thirdparty/getThirdparty.sh +++ b/app/thirdparty/getThirdparty.sh @@ -15,3 +15,9 @@ unzip pdfjs-1.8.188-dist.zip -d pdfjs # tarballjs wget https://github.com/ankitrohatgi/tarballjs/archive/master.zip unzip master.zip -d tarballjs + +# numericjs +mkdir -p numericjs +cd numericjs +wget http://www.numericjs.com/lib/numeric-1.2.6.min.js +cd ..