wMathMatrix:矩阵数学

  • X9_971916
    了解作者
  • 1.4MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-07 22:22
    上传日期
模块::数学矩阵 矩阵数学的抽象实现。 MathMatrix 引入了类 Matrix,这是一个多维结构,在最简单的情况下,它是一个二维矩阵。 特定形式的矩阵也可以归类为向量。 MathMatrix 严重依赖 MathVector,它引入了 VectorAdapter。 Vector 适配器是抽象接口的一种实现,是一种定义如何将数据解释为向量的链接。 适配器是一个特殊的对象,它使算法更加抽象,并为非常不同的向量指定格式使用相同的代码。 使用模块 MathMatrix 对矩阵进行算术运算,对矩阵进行三角剖分、置换或变换,获得线性方程组的特定或一般解,获得 LU、QR 分解,用于 SVD 或 PCA。 此外,Matrix 是一种方便高效的数据容器。 您可以使用它来连续存储多维数据。 从存储库中尝试 git clone https://github.com/Wandalen/wMathMatr
wMathMatrix-master.zip
内容介绍
# module::MathMatrix [![status](https://github.com/Wandalen/wMathMatrix/actions/workflows/StandardPublish.yml/badge.svg)](https://github.com/Wandalen/wMathMatrix/actions/workflows/StandardPublish.yml) [![stable](https://img.shields.io/badge/stability-stable-brightgreen.svg)](https://github.com/emersion/stability-badges#stable) Abstract implementation of matrix math. MathMatrix introduces class Matrix, which is a multidimensional structure which, in the most trivial case, is a 2D matrix. A matrix of specific form could also be classified as a vector. MathMatrix heavily relly on MathVector, which introduces VectorAdapter. A Vector adapter is an implementation of the abstract interface, a kind of link that defines how to interpret data as the vector. An adapter is a special object to make algorithms more abstract and to use the same code for very different formats of vector specifying. Use module MathMatrix for arithmetic operations with matrices, to triangulate, permutate or transform matrix, to get a particular or the general solution of a system of linear equations, to get LU, QR decomposition, for SVD or PCA. Also, Matrix is a convenient and efficient data container. You may use it to continuously store multidimensional data. ### Try out from the repository ``` git clone https://github.com/Wandalen/wMathMatrix cd wMathMatrix will .npm.install node sample/trivial/Sample.s ``` Make sure you have utility `willbe` installed. To install willbe: `npm i -g willbe@stable`. Willbe is required to build of the module. ### To add to your project ``` npm add 'wmathmatrix@stable' ``` `Willbe` is not required to use the module in your project as submodule. ### Why? Because this implementation of linear algebra abstracts algorithms and data thanks smart data structures, minimizing the need to write extensive code and enabling building up more complex systems on top of it. The instance of the matrix does not own data buffer, but only information on how to interpret ( map ) the buffer into K-dimensional space. The matrix, as an advanced link, enables the zero-copy principle. The matrix can be used with either arithmetic purposes or to orchestrate multidimensional data. Features of this implementation of matrix mathematics are: - **Cleanliness**: the module does not inject methods, does not contaminate or alter the standard interface. - **Zero-copy principle**: the module makes it possible to avoid redundant moving of memory thanks to the concept of the adapter. - **Simplicity**: a regular array or typed buffer could be interpreted as a vector, no need to use special classes. - **Usability**: the readability and conciseness of the code which uses the module are as important for us as the performance of the module. - **Flexibility**: it's highly flexible, thanks to strides. - **Reliability**: the module has good test coverage. - **Accessibility**: the module has documentation. - **Functional programming principles**: the module uses some principles of functional programming. - **Native implementation**: under the NodeJS, it optionally uses binding to the native implementation of [BLAS-like](https://github.com/flame/blis) library ( not ready ). - **GPGPU** implementation: under the browser, it optionally uses WebGL ( not ready ). - **Performance**: the optimized build has high performance ( not ready ). ### Concepts of vector and vector adapter The vector in this module means an ordered set of scalars. The vector is not an object, but an abstraction. Vector adapter is an abstract interface and its implementation is a kind of link that defines how to interpret data as the vector. The interface of the adapter has many implementations. To get more details have a look module MathVector. ### Concept of Matrix Matrix is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns. By default, matrix has two dimensions. In our implementation matrix might have more than two dimensions. ![Matrix](./doc/img/MatrixConcept.png) ### Static routine `Make` Let's creates a matrix with specified dimensions. ```js var matrix = _.Matrix.Make([ 2, 2 ]); console.log( `matrix :\n${ matrix }` ); /* log : matrix : Matrix.F32x.2x2 :: +0 +0 +0 +0 */ ``` The created matrix `matrix` has dimension `2x2`, which is specified by the argument in the call of static routine. ### Explicit constructor Matrix also could be created by explicitly calling the constructor. To do that, at least 3 options should be specified. ```js var matrix = new _.Matrix ({ buffer : [ 1, 2, 3, 4 ], dims : [ 2, 2 ], inputRowMajor : 1, }); console.log( `matrix :\n${ matrix }` ); /* log : matrix : Matrix.Array.2x2 :: +1 +2 +3 +4 */ ``` The constructor receives buffer, dimensions, and hint to calculate effective strides. Created matrix `matrix` has dimensions `2х2`, what is specified explicitly. ### Static routine `MakeSquare` Let's create a square matrix from a passed buffer or a given dimension. ```js var matrix = _.Matrix.MakeSquare ([ 1, 2, 3, 4 ]); console.log( `matrix :\n${ matrix }` ); /* log : matrix : Matrix.Array.2x2 :: +1 +2 +3 +4 */ ``` Static routine `MakeSquare` deduces dimension `2x2` from the length of the vector that is passed as the input. ```js var matrix = _.Matrix.MakeSquare( 2 ); console.log( `matrix :\n${ matrix }` ); /* log : matrix : Matrix.F32x.2x2 :: +0 +0 +0 +0 */ ``` The dimension `2x2` is given by the scalar` 2`. Scalar is sufficient to deduce dimensions because the created matrix is square. ### Standard strides An object of the class `Matrix` could be created by an explicit call of the constructor. ```js var matrix = new _.Matrix ({ buffer : [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ], dims : [ 3, 2 ], inputRowMajor : 0, }); console.log( `matrix :\n${ matrix }` ); /* log : matrix : Matrix.Array.3x2 :: +1 +4 +2 +5 +3 +6 */ console.log( `effective strides :\n${ matrix.stridesEffective }` ); /* log : effective strides : [ 1, 3 ] */ ``` Three options are the minimum amount of information required to call the matrix constructor. Data buffer `buffer`, information about dimensions `dims`, and the option `inputRowMajor` - hints on whether the input data will be transposed. By default, the elements in the buffer are in such sequence: ![StandardStridesInputRowMajor0.png](doc/img/StandardStridesInputRowMajor0.png) Option `inputRowMajor : 1` alter algorithm of strides calculation. ```js var matrix = new _.Matrix ({ buffer : [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ], dims : [ 3, 2 ], inputRowMajor : 1, }); console.log( `matrix :\n${ matrix }` ); /* log : matrix : Matrix.Array.3x2 :: +1 +2 +3 +4 +5 +6 */ console.log( `effective strides :\n${ matrix.stridesEffective }` ); /* log : effective strides : [ 2, 1 ] */ ``` With `inputRowMajor : 1` strides are `[ 2, 1 ]`, instead of `[ 1, 2 ]` of the previous example. Sequence looks like that: ![StandardStridesInputRowMajor1.png](doc/img/StandardStridesInputRowMajor1.png) The option `inputRowMajor` shows the constructor to calculate strides. Alternatively, it is possible to specify strides explicitly: ```js var matrix = new _.Matrix ({ buffer : [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ], dims : [ 3, 2 ], strides : [ 2, 1 ], }); console.log( `matrix :\n${ matrix }` ); /* log : matrix : Matrix.Array.3x2 :: +1 +2 +3 +4 +5 +6 */ console.log( `effective strides :\n${ matrix.stridesEffective }` ); /* log : effective strides : [ 2, 1 ] */ ``` Unlike the previous example, strides in this example are specified explicitly, but the result is the same. ![StandardExplicitStrides.png](doc/img/StandardExplicitStrides.png) The diagram shows how the buffer maps into the matrix. All scalars follow one by one. By default, `strides` are calculated so that all scalars go one after another. The option `inputRowMajor` specifies in which sequence row and column go. Alternatively, one of the [static routines](doc/eng/tutorial/MatrixCreation.md) `_.Matrix.Make*` may be used to create a matrix.
评论
    相关推荐
    • Tastebuds:食品订购网站https存储
      食品订购网站的存储库 Tastebuds是一个独特的食品订购网站,您可以在其中自由定制自己的食品。 最好的部分是,您可以根据需要,日期和时间安排下达订单。 味蕾本身就是一个组织,不与其他餐馆捆绑以提供食物。 ...
    • 存储资料
      NULL 博文链接:https://hongyabing.iteye.com/blog/1569369
    • LearningDirectX11:https的源代码存储
      DirectX 12中的纹理和照明 的源代码存储库 控制项 钥匙 行动 W 向前移动相机 A 向左移动相机 S 向后移动相机 D 向右移动相机 Q 向上平移相机 E 向下平移相机 Esc 关闭申请 Alt + Enter 切换全屏模式
    • 存储过程
      NULL 博文链接:https://canglang0.iteye.com/blog/1513344
    • kubemacro-hub:https的宏存储
      KubeMacro集线器 宏存储库。
    • 文档存储
      NULL 博文链接:https://wangjichun.iteye.com/blog/2057313
    • fno-specification:https存储
      存储库 快速开始 编辑dev.html 确保所有本地资产都在resources文件夹中,并且dev.html文件中的链接是相对的(这很重要,因为发布脚本会创建多个嵌套路径) 将快照另存为index.html 运行node publish.js index....
    • commons:此存储库已弃用。 访问 https
      Codenvy 公共类 此存储库已弃用。 访问
    • nur-packages:我的个人NUR存储https
      神经包装 我的个人存储
    • LegacyVEX:https
      这是我用于个人项目的Legacy VEX设备的待添加(TBA)存储库。 如果我的代码可以帮助您完成任务,请随时使用它-如果您使用我的代码的大部分内容,请给我发送代码链接,并在注释部分中将其归功于我,谢谢。 如果您是...