comparison liboctave/fCMatrix.cc @ 12065:899122410ea5 release-3-2-x

more fixes & tests for matrix multiply
author Jaroslav Hajek <highegg@gmail.com>
date Sun, 23 Aug 2009 11:11:27 +0200
parents 8e8da2c36e7e
children
comparison
equal deleted inserted replaced
12064:8e8da2c36e7e 12065:899122410ea5
3742 %!assert(single([1 i])*single([i 0])', single(-i)); 3742 %!assert(single([1 i])*single([i 0])', single(-i));
3743 */ 3743 */
3744 3744
3745 /* Test some simple identities 3745 /* Test some simple identities
3746 %!shared M, cv, rv 3746 %!shared M, cv, rv
3747 %! M = randn(10,10)+i*rand(10,10); 3747 %! M = single(randn(10,10))+i*single(rand(10,10));
3748 %! cv = randn(10,1)+i*rand(10,1); 3748 %! cv = single(randn(10,1))+i*single(rand(10,1));
3749 %! rv = randn(1,10)+i*rand(1,10); 3749 %! rv = single(randn(1,10))+i*single(rand(1,10));
3750 %!assert([M*cv,M*cv],M*[cv,cv],5e-7) 3750 %!assert([M*cv,M*cv],M*[cv,cv],5e-6)
3751 %!assert([rv*M;rv*M],[rv;rv]*M,5e-7) 3751 %!assert([M.'*cv,M.'*cv],M.'*[cv,cv],5e-6)
3752 %!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-7) 3752 %!assert([M'*cv,M'*cv],M'*[cv,cv],5e-6)
3753 %!assert([rv*M;rv*M],[rv;rv]*M,5e-6)
3754 %!assert([rv*M.';rv*M.'],[rv;rv]*M.',5e-6)
3755 %!assert([rv*M';rv*M'],[rv;rv]*M',5e-6)
3756 %!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-6)
3753 */ 3757 */
3754 3758
3755 static const char * 3759 static const char *
3756 get_blas_trans_arg (bool trans, bool conj) 3760 get_blas_trans_arg (bool trans, bool conj)
3757 { 3761 {
3844 F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (ctransa, 1), 3848 F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (ctransa, 1),
3845 lda, tda, 1.0, a.data (), lda, 3849 lda, tda, 1.0, a.data (), lda,
3846 b.data (), 1, 0.0, c, 1 3850 b.data (), 1, 0.0, c, 1
3847 F77_CHAR_ARG_LEN (1))); 3851 F77_CHAR_ARG_LEN (1)));
3848 } 3852 }
3849 else if (a_nr == 1 && ! conja) 3853 else if (a_nr == 1 && ! conja && ! conjb)
3850 { 3854 {
3851 const char *crevtransb = get_blas_trans_arg (! transb, conjb); 3855 const char *crevtransb = get_blas_trans_arg (! transb, conjb);
3852 F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (crevtransb, 1), 3856 F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (crevtransb, 1),
3853 ldb, tdb, 1.0, b.data (), ldb, 3857 ldb, tdb, 1.0, b.data (), ldb,
3854 a.data (), 1, 0.0, c, 1 3858 a.data (), 1, 0.0, c, 1