diff --git a/package-lock.json b/package-lock.json index 2507829..49506c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3321,10 +3321,11 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", "dev": true, + "license": "MIT", "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -7112,9 +7113,9 @@ "dev": true }, "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", "dev": true, "requires": { "argparse": "^1.0.7", diff --git a/src/types/opencv/core_array.ts b/src/types/opencv/core_array.ts index 24f264a..f0b64b7 100644 --- a/src/types/opencv/core_array.ts +++ b/src/types/opencv/core_array.ts @@ -2654,28 +2654,6 @@ export declare function subtract( */ export declare function sum(src: InputArray): Scalar; -/** - * wrap [SVD::backSubst] - */ -export declare function SVBackSubst( - w: InputArray, - u: InputArray, - vt: InputArray, - rhs: InputArray, - dst: OutputArray, -): void; - -/** - * wrap [SVD::compute] - */ -export declare function SVDecomp( - src: InputArray, - w: OutputArray, - u: OutputArray, - vt: OutputArray, - flags?: int, -): void; - /** * The function [cv::theRNG] returns the default random number generator. For each thread, there is a * separate random number generator, so you can use the function safely in multi-thread environments. diff --git a/test/linearAlgebra.test.ts b/test/linearAlgebra.test.ts new file mode 100644 index 0000000..8c2769b --- /dev/null +++ b/test/linearAlgebra.test.ts @@ -0,0 +1,68 @@ +import { setupOpenCv } from "./cv"; + +beforeAll(setupOpenCv); + +describe("Linear Algebra Functions", () => { + it("should have solve, invert, and eigen functions", () => { + // These functions are available in opencv.js + expect(typeof cv.solve).toBe("function"); + expect(typeof cv.invert).toBe("function"); + expect(typeof cv.eigen).toBe("function"); + }); + + it("should have DECOMP constants", () => { + // DECOMP constants are available + expect(cv.DECOMP_LU).toBe(0); + expect(cv.DECOMP_SVD).toBe(1); + expect(cv.DECOMP_EIG).toBe(2); + expect(cv.DECOMP_CHOLESKY).toBe(3); + expect(cv.DECOMP_QR).toBe(4); + expect(cv.DECOMP_NORMAL).toBe(16); + }); + + it("should NOT have SVDecomp and SVBackSubst functions", () => { + // SVDecomp and SVBackSubst are not compiled into opencv.js + // These functions were incorrectly included in TypeScript definitions before + // Using bracket notation to avoid TypeScript compilation errors + expect((cv as any)["SVDecomp"]).toBeUndefined(); + expect((cv as any)["SVBackSubst"]).toBeUndefined(); + }); + + it("should demonstrate solve function works", () => { + // Create a simple 2x2 linear system and verify solve can be called + // Using arbitrary matrix values just to test the function executes + const A = cv.matFromArray(2, 2, cv.CV_64F, [2, 1, 1, 3]); + const b = cv.matFromArray(2, 1, cv.CV_64F, [5, 6]); + const x = new cv.Mat(); + + const result = cv.solve(A, b, x, cv.DECOMP_LU); + + // Just verify the function executes without error + expect(typeof result).toBe("boolean"); + expect(x.rows).toBe(2); + expect(x.cols).toBe(1); + + // Clean up + A.delete(); + b.delete(); + x.delete(); + }); + + it("should demonstrate invert function works", () => { + // Create a simple invertible 2x2 matrix to test the function + // Using arbitrary matrix values just to test the function executes + const A = cv.matFromArray(2, 2, cv.CV_64F, [4, 7, 2, 6]); + const Ainv = new cv.Mat(); + + const det = cv.invert(A, Ainv, cv.DECOMP_LU); + + // Just verify the function executes without error + expect(typeof det).toBe("number"); + expect(Ainv.rows).toBe(2); + expect(Ainv.cols).toBe(2); + + // Clean up + A.delete(); + Ainv.delete(); + }); +});