summaryrefslogtreecommitdiffstats
path: root/admin/survey/excel/PHPExcel/Shared/JAMA/utils
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
commit19985dbb8c0aa66dc4bf7905abc1148de909097d (patch)
tree2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /admin/survey/excel/PHPExcel/Shared/JAMA/utils
download1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip
Diffstat (limited to 'admin/survey/excel/PHPExcel/Shared/JAMA/utils')
-rw-r--r--admin/survey/excel/PHPExcel/Shared/JAMA/utils/Error.php82
-rw-r--r--admin/survey/excel/PHPExcel/Shared/JAMA/utils/Maths.php43
2 files changed, 125 insertions, 0 deletions
diff --git a/admin/survey/excel/PHPExcel/Shared/JAMA/utils/Error.php b/admin/survey/excel/PHPExcel/Shared/JAMA/utils/Error.php
new file mode 100644
index 0000000..c895aa9
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/Shared/JAMA/utils/Error.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * @package JAMA
+ *
+ * Error handling
+ * @author Michael Bommarito
+ * @version 01292005
+ */
+
+//Language constant
+define('JAMALANG', 'EN');
+
+
+//All errors may be defined by the following format:
+//define('ExceptionName', N);
+//$error['lang'][ExceptionName] = 'Error message';
+$error = array();
+
+/*
+I've used Babelfish and a little poor knowledge of Romance/Germanic languages for the translations here.
+Feel free to correct anything that looks amiss to you.
+*/
+
+define('PolymorphicArgumentException', -1);
+$error['EN'][PolymorphicArgumentException] = "Invalid argument pattern for polymorphic function.";
+$error['FR'][PolymorphicArgumentException] = "Modèle inadmissible d'argument pour la fonction polymorphe.".
+$error['DE'][PolymorphicArgumentException] = "Unzulässiges Argumentmuster für polymorphe Funktion.";
+
+define('ArgumentTypeException', -2);
+$error['EN'][ArgumentTypeException] = "Invalid argument type.";
+$error['FR'][ArgumentTypeException] = "Type inadmissible d'argument.";
+$error['DE'][ArgumentTypeException] = "Unzulässige Argumentart.";
+
+define('ArgumentBoundsException', -3);
+$error['EN'][ArgumentBoundsException] = "Invalid argument range.";
+$error['FR'][ArgumentBoundsException] = "Gamme inadmissible d'argument.";
+$error['DE'][ArgumentBoundsException] = "Unzulässige Argumentstrecke.";
+
+define('MatrixDimensionException', -4);
+$error['EN'][MatrixDimensionException] = "Matrix dimensions are not equal.";
+$error['FR'][MatrixDimensionException] = "Les dimensions de Matrix ne sont pas égales.";
+$error['DE'][MatrixDimensionException] = "Matrixmaße sind nicht gleich.";
+
+define('PrecisionLossException', -5);
+$error['EN'][PrecisionLossException] = "Significant precision loss detected.";
+$error['FR'][PrecisionLossException] = "Perte significative de précision détectée.";
+$error['DE'][PrecisionLossException] = "Bedeutender Präzision Verlust ermittelte.";
+
+define('MatrixSPDException', -6);
+$error['EN'][MatrixSPDException] = "Can only perform operation on symmetric positive definite matrix.";
+$error['FR'][MatrixSPDException] = "Perte significative de précision détectée.";
+$error['DE'][MatrixSPDException] = "Bedeutender Präzision Verlust ermittelte.";
+
+define('MatrixSingularException', -7);
+$error['EN'][MatrixSingularException] = "Can only perform operation on singular matrix.";
+
+define('MatrixRankException', -8);
+$error['EN'][MatrixRankException] = "Can only perform operation on full-rank matrix.";
+
+define('ArrayLengthException', -9);
+$error['EN'][ArrayLengthException] = "Array length must be a multiple of m.";
+
+define('RowLengthException', -10);
+$error['EN'][RowLengthException] = "All rows must have the same length.";
+
+/**
+ * Custom error handler
+ * @param int $num Error number
+ */
+function JAMAError($errorNumber = null) {
+ global $error;
+
+ if (isset($errorNumber)) {
+ if (isset($error[JAMALANG][$errorNumber])) {
+ return $error[JAMALANG][$errorNumber];
+ } else {
+ return $error['EN'][$errorNumber];
+ }
+ } else {
+ return ("Invalid argument to JAMAError()");
+ }
+}
diff --git a/admin/survey/excel/PHPExcel/Shared/JAMA/utils/Maths.php b/admin/survey/excel/PHPExcel/Shared/JAMA/utils/Maths.php
new file mode 100644
index 0000000..5488e00
--- /dev/null
+++ b/admin/survey/excel/PHPExcel/Shared/JAMA/utils/Maths.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * @package JAMA
+ *
+ * Pythagorean Theorem:
+ *
+ * a = 3
+ * b = 4
+ * r = sqrt(square(a) + square(b))
+ * r = 5
+ *
+ * r = sqrt(a^2 + b^2) without under/overflow.
+ */
+function hypo($a, $b) {
+ if (abs($a) > abs($b)) {
+ $r = $b / $a;
+ $r = abs($a) * sqrt(1 + $r * $r);
+ } elseif ($b != 0) {
+ $r = $a / $b;
+ $r = abs($b) * sqrt(1 + $r * $r);
+ } else {
+ $r = 0.0;
+ }
+ return $r;
+} // function hypo()
+
+
+/**
+ * Mike Bommarito's version.
+ * Compute n-dimensional hyotheneuse.
+ *
+function hypot() {
+ $s = 0;
+ foreach (func_get_args() as $d) {
+ if (is_numeric($d)) {
+ $s += pow($d, 2);
+ } else {
+ throw new Exception(JAMAError(ArgumentTypeException));
+ }
+ }
+ return sqrt($s);
+}
+*/