[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Bit equivalent matrix multiplication in oct/mex files

**From**: |
Henry Gomersall |

**Subject**: |
Bit equivalent matrix multiplication in oct/mex files |

**Date**: |
Thu, 16 Feb 2012 13:19:27 +0000 |

I'm writing an optimised inner loop in C++ using the oct interface.
As part of the loop I need to do a small 2x2 matrix-vector
multiplication.
Initially I hand coded this matrix-vector multiplication as a series of
multiplication and additions. What I noticed was that this was not
bit-equivalent to Octave performing the same operation, which is not
wholly unexpected.
Now, this is no problem when writing pure .oct files as I can just
create a Matrix and a ColumnVector and just multiply them. This
operation *does* seem to be bit-identical to running the op as octave
code.
I would like to be able to write my c++ such that the inner loop is not
tied to Octave, but will compile to produce a .mex for Matlab as well
(using suitable #ifdefs) using a different interface function. This
means I don't really want the inner loop to use Octave specific classes.
The questions are these:
1) How do I implement a bit equivalent matrix vector multiplication in
C++ without using octave specific code?
2) Is this operation similarly bit equivalent to the same Matlab
operation? If not, does anyone know what implementation Matlab uses (I
presume it's just BLAS?)
Pulling in a BLAS library to do a 2x2 matrix multiplication seems like
overkill to me.
Cheers,
Henry

**Bit equivalent matrix multiplication in oct/mex files**,
*Henry Gomersall* **<=**