# jama **Repository Path**: liuher/jama ## Basic Information - **Project Name**: jama - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 15 - **Created**: 2023-12-28 - **Last Updated**: 2023-12-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # jama ## 简介 > 基本线性代数包,用于构造和操作真实密集矩阵的库。 ![preview.gif](preview/preview.gif) ## 下载安装 ```shell ohpm install @ohos/jama ``` OpenHarmony ohpm环境配置等更多内容,请参考 [如何安装OpenHarmony ohpm包](https://gitee.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.md) 。 ## 使用说明 1. 引入依赖 ``` import { Matrix } from '@ohos/jama' ``` 2. 创建矩阵 ``` let array: number[][] = [[1., 2., 3], [4., 5., 6.], [7., 8., 10.]] let A: Matrix = new Matrix(array); let array2: number[][] = [[1,1,1],[1,1,1],[1,1,1]] let B: Matrix = new Matrix(array2); let x: Matrix = A.plus(B); ``` ## 接口说明 1. 矩阵加法 ``` let array: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] let A: Matrix = new Matrix(array); let array2: number[][] = [[9, 8, 7], [6, 5, 4], [3, 2, 1]] let B: Matrix = new Matrix(array2); let C = A.plus(B) ``` 2. 矩阵减法 ``` let array: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] let A: Matrix = new Matrix(array); let array2: number[][] = [[9, 8, 7], [6, 5, 4], [3, 2, 1]] let B: Matrix = new Matrix(array2); let C = A.minus(B) ``` 3. 矩阵乘法 ``` let array: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] let A: Matrix = new Matrix(array); let array2: number[][] = [[9, 8, 7], [6, 5, 4], [3, 2, 1]] let B: Matrix = new Matrix(array2); let C = A.times(B) ``` 4. 矩阵左除除法 ``` let array: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] let A: Matrix = new Matrix(array); let array2: number[][] = [[9, 8, 7], [6, 5, 4], [3, 2, 1]] let B: Matrix = new Matrix(array2); let C = A.arrayLeftDivide(B) ``` 5. 矩阵缩放 ``` let array: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] let A: Matrix = new Matrix(array); let C = A.times(2) // 矩阵元素扩大2倍 ``` 6. 矩阵求逆 ``` let array: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] let A: Matrix = new Matrix(array); let C = A.inverse() ``` 7. 矩阵转置 ``` let array: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] let A: Matrix = new Matrix(array); let C = A.transpose() ``` 8. 矩阵范式 ``` let array: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] let A: Matrix = new Matrix(array); let C = A.cond() ``` ## 约束与限制 在下述版本验证通过: - DevEco Studio 版本: 4.1 Canary(4.1.3.317) - OpenHarmony SDK:API11 (4.1.0.36) ## 目录结构 ```` |---- jama | |---- entry # 示例代码文件夹 | |---- library # jama库文件夹 | |---- src | |---- main | |---- ets | |---- components | |---- util # 工具类文件 | |---- Maths.ts # 指数计算类 | |---- CholeskyDecomposition.ts # 乔列斯基分解类 | |---- EigenvalueDecomposition.ts # 矩阵的特征值和特征向量 | |---- LUDecomposition.ts # LU分解 | |---- Matrix.ts # 矩阵类 | |---- QRDecomposition.ts # QR分解 | |---- SingularValueDecomposition.ts # 奇异值分解 | |---- index.ets # 对外接口 | |---- README.md # 安装使用方法 ```` ## 贡献代码 使用过程中发现任何问题都可以提 [Issue](https://gitee.com/openharmony-sig/jama/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://gitee.com/openharmony-sig/jama/pulls) 。 ## 开源协议 本项目基于 [Apache License 2.0](https://gitee.com/openharmony-sig/jama/blob/master/LICENSE) ,请自由地享受和参与开源。