![]() |
Blitz Bugs : |
From: Sandy Jackson (winsthrop_phd_at_[hidden])
Date: 2004-03-15 00:24:35
I am not sure what the what the folowing expression is suppose to
return for type Array<double, 2>:
C = A*B;
If it is standard matrix multiplication, then, I believe that I have
found a bug in the implementation. If it is not intednded to be
standard matrix multiplication, what does it return ?
The following short example illustrates the problem:
// Inclusion of C++ standard library header files
#include <iomanip>
#include <iostream>
#include <istream>
#include <ostream>
#include <fstream>
using namespace std;
// Inclusion of C++ non-standard library header files
#include <blitz/array.h>
using namespace blitz;
typedef Array<double, 2> Matrix;
int main()
{
Matrix A(4,4);
A = 1,2,3,4,2,2,2,2,3,3,3,3,4,4,4,4;
Matrix B(4,2);
B = 1,2,1,2,1,2,1,2;
Matrix C(4,4), Bo(4,4);
C = 0;
Bo = 0;
Bo = A*B;
for (int i = 0; i < A.rows(); i++ )
for ( int j = 0; j < B.cols(); j++ )
for( int k = 0; k < A.cols(); k++ )
C(i,j) += A(i,k) * B(k,j);
cout << "A = " << A << endl << " B = " << B << endl;
cout << " My A*B = " << C << endl;
cout << " Blitz A*B = " << Bo << endl;
return 0;
}
I compiled the above code using gcc-3.3.1-3 for i-686-pc-cygwin.
I get the following results.
A = 4 x 4
[ 1 2 3 4
2 2 2 2
3 3 3 3
4 4 4 4 ]
B = 4 x 2
[ 1 2
1 2
1 2
1 2 ]
My A*B = 4 x 4
[ 10 20 0 0
8 16 0 0
12 24 0 0
16 32 0 0 ]
Blitz A*B = 4 x 4
[ 1 4 3 8
2 4 2 4
1.5915e-312 6.10782e-260 6.61505e-314 8.7214e-312
0 0 0 0 ]
=====
May God Bless You
Sandy R. Jackson
"Because He lives, I can face tomorrow; Because he lives, all fear is gone. Because, I know He holds the future. And life is worth the living - just because He lives."
William Gather, 1971