Coder Social home page Coder Social logo

mmx's Introduction

mmx

Multithreaded matrix operations on N-D arrays (a Matlab plug-in)

mmx treats an N-D matrix of double precision values as a set of pages of 2D matrices, and performs various matrix operations on those pages.

mmx uses multithreading over the higher dimensions (coarse-grained multithreading) to achieve good performance. Full singleton expansion is available for most operations.

Matrix multiplication:

C = mmx('mult', A, B)

is equivalent to

for i=1:N, 
  C(:,:,i) = A(:,:,i) * B(:,:,i); 
end

Singleton expansion is enabled on all dimensions so for example if

A = randn(5,4,3,10,1); 
B = randn(4,6,3,1 ,6); 
C = randn(5,6,3,10,6); 

then

C = mmx('mult', A, B)

is equivalent to

for i = 1:3 
  for j = 1:10 
    for k = 1:6 
      C(:,:,i,j,k) = A(:,:,i,j,1) * B(:,:,i,1,k); 
    end 
  end 
end

Transposition:

C = mmx('mult', A, B, mod)

where mod is a modifier string, will transpose one or both of A and B. Possible values for mod are 'tn', 'nt' and 'tt' where 't' stands for 'transposed' and 'n' for 'not-transposed'. For example

>> size(mmx('mult',randn(4,2),randn(4,2),'tn')) 
ans = 2 2

Squaring:

C = mmx('square', A, [])     % C = A*A' 
C = mmx('square', A, [],'t') % C = A'*A
C = mmx('square', A, B)      % C = (A*B'+B*A') / 2
C = mmx('square', A, B, 't') % C = (A'*B+B'*A) / 2

Cholesky factorization:

C = mmx('chol', A, []) % C = chol(A)

Solving linear equations:

C = mmx('backslash', A, B) % C = A\B

Unlike other mmx commands, 'backslash' does not support singleton expansion. If A is square, mmx will use LU factorization, otherwise it will use QR factorization. In the underdetermined case, (i.e. when size(A,1) < size(A,2)), mmx will give the least-norm solution which is equivalent to C = pinv(A)*B, (unlike Matlab's mldivide).

C = mmx('backslash', A, B, 'U') or mmx('backslash', A, B, 'L') will perform C = A\B assuming that A is upper or lower triangular, respectively.

C = mmx('backslash', A, B, 'P') will perform C = A\B assuming that A is symmetric positive definite.

mmx(n) does thread control: mmx will automatically start a number of threads equal to the number of available processors, however the number can be set manually to n using the command mmx(n). mmx(0) clears the threads from memory.

IMPORTANT NOTE: The functions which assume special types of square matrices as input ('chol' or 'backslash' for 'U','L' or 'P' modifiers) do not check that the inputs are what you say they are, and produce no error if they are not. Caveat computator.

Compilation:

Run build_mmx. Type help build_mmx to read about compilation issues and options.

Performance:

performance comparison

mmx's People

Contributors

yuvaltassa avatar adamcooman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.