Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

matvec

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

matvec

Fast matrix transforms

  • 0.1.7
  • PyPI
  • Socket score

Maintainers
1

matvec

A domain-specific language for fast graph shift operations. This implements mathematical fields on numbers, n-dimensional column vectors, and n-by-n sparse matrices.

License: Apache Software License
Author: Emmanouil (Manios) Krasanakis
Dependencies: numpy

:zap: Quickstart

Creating a 5-dimensional vector (can use numpy arrays as inputs interchangeably with lists everywhere):

from matvec import Vector
x = Vector([1, 2, 3, 4, 5])

Creating a 5x5 sparse matrix A in coo-format with non-zero elements A[1,2]=9 and A[3,0]=21

from matvec import Matrix
A = Matrix([1, 2],
           [3, 0],
           [9, 21],
           5)

Print the outcome of matrix-vector multiplication:

print(A*x)

Print the outcome of left-multiplying the transpose of x with A:

print(x*A)

:fire: Features

:rocket: Parallelized matrix-vector multiplication.
:chart_with_downwards_trend: Memory reuse optimization.
:mag: numpy compatibility.
:factory: Common arithmetic operations.

:volcano: Benchmark

Benchmarks tested on a machine with 2.6 GHz CPU base clock and up to 4.4 GHz turbo boost, 12 logical cores, and 16GB DDR3 RAM. They span vectors of 1.E4 to 1.E6 elements and matrices with up to 100x the number of non-zeroes (that is, if the matrices represented graphs, node degrees would be up to 100).

For a lot of non-zeroes paralellization may be worse than scipy.

Tasknumpy/scipymatvec
Create new vector or array0.019 sec0.019 sec
1000 temp. additions of 1.E6 vectors1.897 sec1.321 sec
Create matrix0.505 sec0.183 sec
Sparse matrix with vector multiplication0.269 sec0.103 sec

benchmarks

:memo: List of Operations

  • Full arithmetic operations * + - / == < > <= >= between vectors and other vectors or scalars.
  • Matrix-vector multiplication * (both left and right).
  • Element access and assignment for vectors with [].
  • Masking, such as y = x[x>0].
  • matvec.clear() clears cache.

FAQs


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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc