New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@dandre3000/matrix

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dandre3000/matrix

Matrix library

latest
Source
npmnpm
Version
0.5.1-alpha
Version published
Maintainers
1
Created
Source

@dandre3000/matrix

Matrix math library.

Usage

$ npm install @dandre3000/matrix

import { Matrix } from '@dandre3000/matrix'

/*
  {
    rows: 2,
    columns: 2,
    data: Float64Array[
      1, 2,
      3, 4
    ]
  }
*/
const a = new Matrix(2, 2, [1, 2, 3, 4])

/*
  {
    rows: 2,
    columns: 2,
    data: Float64Array[
      5, 6,
      7, 8
    ]
  }
*/
const b = new Matrix(2, 2, [5, 6, 7, 8])

/*
  {
    rows: 2,
    columns: 2,
    data: Float64Array[
      6, 8,
      10, 12
    ]
  }
*/
a.add(b)

API

import { new Matrix } from '@dandre3000/matrix'

/*
  {
    rows: 1,
    columns: 1,
    data: Float64Array[0]
  }
*/
new Matrix(1, 1)

/*
  {
    rows: 2,
    columns: 2,
    data: Float64Array[
      2, 2,
      0, 0
    ]
  }
*/
new Matrix(2, 2, [2, 2])

/*
  {
    rows: 4,
    columns: 1
    data: Float64Array[
      1,
      2,
      3,
      4
    ]
  }
*/
new Matrix(4, 1, [1, 2, 3, 4, 5])

/*
  {
    rows: 1,
    columns: 4,
    data: Float64Array[6, 7, 8, 9]
  }
*/
new Matrix(1, 4, [6, 7, 8, 9])

const buffer = new ArrayBuffer(6 * 8)
const array = new Float64Array(buffer, 0, 4)
const array2 = new Float64Array(buffer, 16, 4)

array2[0] = 1
array2[1] = 1

/*
  {
    rows: 2,
    columns: 2,
    data: Float64Array[
      0, 0,
      1, 1
    ]
  }
*/
const a = new Matrix(2, 2, array)

// true
a.data === array

/*
  {
    rows: 2,
    columns: 2,
    data: Float64Array[
      1, 1,
      0, 0
    ]
  }
*/
const b = new Matrix(2, 2, array2)

// true
b.data === array2

import { Matrix } from '@dandre3000/matrix'

const a = new Matrix(3, 3, [
  1, 2, 3,
  4, 5, 6,
  7, 8, 9
])

const b = new Matrix(3, 3, [
  10, 11, 12,
  13, 14, 15,
  16, 17, 18
])

/*
  {
    rows: 3,
    columns: 3,
    data: Float64Array[
      11, 13, 15,
      17, 19, 21,
      23, 25, 27
    ]
  }
*/
a.sum(b)

import { Matrix } from '@dandre3000/matrix'

const a = new Matrix(3, 3, [
  1, 2, 3,
  4, 5, 6,
  7, 8, 9
])

const b = new Matrix(3, 3, [
  10, 11, 12,
  13, 14, 15,
  16, 17, 18
])

/*
  {
    rows: 3,
	columns: 3,
    data: Float64Array[
    -9, -9, -9,
    -9, -9, -9,
    -9, -9, -9
  ]
*/
a.subtract(b)

License

@dandre3000/matrix is published under the GNU General Public License 3.0:

Copyright (c) 2024 DeAundre Payne

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Keywords

algebra

FAQs

Package last updated on 06 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts