diff --git a/.gitignore b/.gitignore index 403adbc..7511ebd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ node_modules .env.*.local # Log files +*.log npm-debug.log* yarn-debug.log* yarn-error.log* diff --git a/package-lock.json b/package-lock.json index ab70c34..051e633 100644 --- a/package-lock.json +++ b/package-lock.json @@ -97,6 +97,7 @@ "integrity": "sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.7", @@ -3047,6 +3048,7 @@ "integrity": "sha512-nV7tYQLe7YsTtzFrfOMIHc5N2hp5lHG2rpYr0aNja9rNljdgcPZLyQRb2YRivTHqTv7lI962UXFURcpStHgyFw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/helper-compilation-targets": "^7.12.16", "@soda/friendly-errors-webpack-plugin": "^1.8.0", @@ -3680,6 +3682,7 @@ "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -3736,6 +3739,7 @@ "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -4268,6 +4272,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001733", "electron-to-chromium": "^1.5.199", @@ -5020,6 +5025,7 @@ "integrity": "sha512-CTJ+AEQJjq5NzLga5pE39qdiSV56F8ywCIsqNIRF0r7BDgWsN25aazToqAFg7ZrtA/U016xudB3ffgweORxX7g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "icss-utils": "^5.1.0", "postcss": "^8.4.33", @@ -5108,6 +5114,7 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -5946,6 +5953,7 @@ "integrity": "sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.4.3", @@ -6132,6 +6140,7 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -8778,6 +8787,7 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -9714,6 +9724,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -12313,6 +12324,7 @@ "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.36.tgz", "integrity": "sha512-mIFvbLgjODfx3Iy1SrxOsiPpDb8Bo3EU+87ioimOZzZTOp15IEdAels70IjBOLO3ZFlLW5AhdwY4dWbXVQKYow==", "license": "MIT", + "peer": true, "dependencies": { "@vue/compiler-dom": "3.4.36", "@vue/compiler-sfc": "3.4.36", @@ -12603,6 +12615,7 @@ "integrity": "sha512-Y0m5oEY1LRuwly578VqluorkXbvXKh7U3rLoQCEO04M97ScRr44afGVkI0FQFsXzysk5OgFAxjZAb9rsGQVihA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.3", "@types/estree": "^1.0.5", @@ -12740,6 +12753,7 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -12857,6 +12871,7 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", diff --git a/src/components/AppNotification.vue b/src/components/AppNotification.vue new file mode 100644 index 0000000..c660f9a --- /dev/null +++ b/src/components/AppNotification.vue @@ -0,0 +1,20 @@ + + + diff --git a/src/components/ErrorDisplay.vue b/src/components/ErrorDisplay.vue new file mode 100644 index 0000000..837a4cc --- /dev/null +++ b/src/components/ErrorDisplay.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/components/MatrixInput.vue b/src/components/MatrixInput.vue index fbc07de..60442e1 100644 --- a/src/components/MatrixInput.vue +++ b/src/components/MatrixInput.vue @@ -11,6 +11,9 @@

+ + +
@@ -93,25 +96,25 @@
+
\ No newline at end of file + diff --git a/src/components/MatrixOperations.vue b/src/components/MatrixOperations.vue deleted file mode 100644 index 1cb9fbf..0000000 --- a/src/components/MatrixOperations.vue +++ /dev/null @@ -1,132 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/OperationButtons.vue b/src/components/OperationButtons.vue deleted file mode 100644 index 8cb7770..0000000 --- a/src/components/OperationButtons.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/composables/useMatrixOperations.js b/src/composables/useMatrixOperations.js index f2852a2..34f0abe 100644 --- a/src/composables/useMatrixOperations.js +++ b/src/composables/useMatrixOperations.js @@ -1,93 +1,112 @@ -import * as math from 'mathjs' +import * as math from 'mathjs'; +import { ref } from 'vue'; -export function useMatrixOperations(props, emit) { - async function calculateDeterminant() { +export function useMatrixOperations() { + const error = ref(null); + + const resetError = () => { + error.value = null; + }; + + const calculateDeterminant = (matrix) => { + resetError(); try { - const det = math.det(props.matrixA) - emit('determinant', det) - } catch (error) { - console.error('Error calculating determinant:', error) + return math.det(matrix); + } catch (err) { + error.value = 'Error calculating determinant: ' + err.message; + return null; } - } + }; - async function addMatrices() { + const addMatrices = (matrixA, matrixB) => { + resetError(); try { - const result = math.add(props.matrixA, props.matrixB) - emit('operation-result', result) - } catch (error) { - console.error('Error adding matrices:', error) + return math.add(matrixA, matrixB); + } catch (err) { + error.value = 'Error adding matrices: ' + err.message; + return null; } - } + }; - async function subtractMatrices() { + const subtractMatrices = (matrixA, matrixB) => { + resetError(); try { - const result = math.subtract(props.matrixA, props.matrixB) - emit('operation-result', result) - } catch (error) { - console.error('Error subtracting matrices:', error) + return math.subtract(matrixA, matrixB); + } catch (err) { + error.value = 'Error subtracting matrices: ' + err.message; + return null; } - } + }; - async function multiplyMatrices() { + const multiplyMatrices = (matrixA, matrixB) => { + resetError(); try { - const result = math.multiply(props.matrixA, props.matrixB) - emit('operation-result', result) - } catch (error) { - console.error('Error multiplying matrices:', error) + return math.multiply(matrixA, matrixB); + } catch (err) { + error.value = 'Error multiplying matrices: ' + err.message; + return null; } - } + }; - async function solveLinearEquations() { + const solveLinearEquations = (matrixA, vector) => { + resetError(); try { - const b = math.matrix(props.vectorB.map(x => [x])) - const solution = math.lusolve(props.matrixA, b).toArray().flat() - emit('solution', solution) - } catch (error) { - console.error('Error solving equations:', error) + const b = math.matrix(vector.map(x => [x])); + return math.lusolve(matrixA, b).toArray().flat(); + } catch (err) { + error.value = 'Error solving equations: ' + err.message; + return null; } - } + }; - async function calculateEigenvalues() { + const calculateEigenvalues = (matrix) => { + resetError(); try { - const result = math.eigs(props.matrixA) - const eigenvalues = result.values.map(v => - typeof v === 'number' ? v.toFixed(4) : - `${v.re.toFixed(4)} + ${v.im.toFixed(4)}i` - ).join(', ') - emit('eigenvalues', eigenvalues) - } catch (error) { - console.error('Error calculating eigenvalues:', error) + const result = math.eigs(matrix); + return result.values + .map(v => + typeof v === 'number' + ? v.toFixed(4) + : `${v.re.toFixed(4)} + ${v.im.toFixed(4)}i` + ) + .join(', '); + } catch (err) { + error.value = 'Error calculating eigenvalues: ' + err.message; + return null; } - } + }; - async function luDecomposition() { + const luDecomposition = (matrix) => { + resetError(); try { - const result = math.lup(props.matrixA) - const lu = { + const result = math.lup(matrix); + return { L: result.L.toArray(), U: result.U.toArray(), - P: result.p.map(i => i + 1) - } - emit('decomposition', { type: 'lu', data: lu }) - } catch (error) { - console.error('Error performing LU decomposition:', error) + P: result.p.map(i => i + 1), + }; + } catch (err) { + error.value = 'Error performing LU decomposition: ' + err.message; + return null; } - } + }; - async function qrDecomposition() { + const qrDecomposition = (matrix) => { + resetError(); try { - const result = math.qr(props.matrixA) - const qr = { + const result = math.qr(matrix); + return { Q: result.Q.toArray(), - R: result.R.toArray() - } - emit('decomposition', { type: 'qr', data: qr }) - } catch (error) { - console.error('Error performing QR decomposition:', error) + R: result.R.toArray(), + }; + } catch (err) { + error.value = 'Error performing QR decomposition: ' + err.message; + return null; } - } + }; return { + error, calculateDeterminant, addMatrices, subtractMatrices, @@ -95,6 +114,6 @@ export function useMatrixOperations(props, emit) { solveLinearEquations, calculateEigenvalues, luDecomposition, - qrDecomposition - } -} \ No newline at end of file + qrDecomposition, + }; +}