Topic: ULTRA-FAST MATRIX MULTIPLICATION


Author: gxo@cs.bham.ac.uk (Giuseppe Olmi)
Date: Wed, 21 Jul 1993 14:18:07 GMT
Raw View
Does anyone have a very fast algorithm for
multiplying a vector by a matrix? I do
not need full MATRIX * MATRIX multiplication,
just:

  vector C = matrix A * vector B.

Currently I am using the class 'matrix' shown
below for both matrices and vectors. Changing
my matrix * vector multiplication algorithm
from subscript to pointer arithmetic increased
the speed quite a bit.

But perhaps someone has written a succinct and
super-swish algorithm that would be even faster.

Your help is appreciated.

Joe Olmi

University Of Birmingham,
United Kingdom.
email: gxo @ cs.bham.ac.uk



///////////////////////////////////////////////////
class matrix
{
private:
  int nr, nc;           // Matrix size (rows * cols)
  double* matrix_data;  // Pointer to start of data

public:
  inline double &element(const int &row, const int &col)
  {
      return matrix_data[row*nc + col];
  }

  etc...etc...
};
///////////////////////////////////////////////////




Author: davisonj@bnr.ca (John M Davison)
Date: 22 Jul 1993 00:23:44 GMT
Raw View
In article <1993Jul21.151807@cs.bham.ac.uk> gxo@cs.bham.ac.uk (Giuseppe Olmi) writes:
>
>Does anyone have a very fast algorithm for
>multiplying a vector by a matrix? I do
>not need full MATRIX * MATRIX multiplication,
>just:
>
>  vector C = matrix A * vector B.
>
>Currently I am using the class 'matrix' shown
>below for both matrices and vectors. Changing
>my matrix * vector multiplication algorithm
>from subscript to pointer arithmetic increased
>the speed quite a bit.
>
>But perhaps someone has written a succinct and
>super-swish algorithm that would be even faster.
>
>Your help is appreciated.

        Unfortunately, it does not appear that the C++ standard will include
any such "succinct and super-swish algorithm" that will help you.
--
John Davison, davisonj@ecn.purdue.edu <---- send followups to THIS ADDRESS!!!!!
(Otherwise your mail will bounce!)  If you work at NT/BNR, please COCOS to
"John Davison".  The information contained in this article isn't necessarily
representative of Northern Telecom or BNR.