Skip to main content

Fast matrix transforms

Project description

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
Dependncies: 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 transpose(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

Experiments run on a machine witj 2.6 GHz CPU base clock, up to 4.4 GHz turbo boost of that clock, 12 logical cores, and 16GB DDR3 RAM. More rigorous evaluation will take place in the future.

Task numpy/scipy matvec
Allocate vectors with 2E6 elements 0.101 sec 0.106 sec
1000 temp. additions with 2E6 elements 4.067 sec 2.265 sec
Allocate matrix with 2E6 non-zeros 0.231 sec 0.073 sec
Sparse matrix with vec multiplication 0.024 sec 0.012 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

matvec-0.0.13-cp310-cp310-win_amd64.whl (20.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page