[Numpy-discussion] A patch to fix a Numeric 24.2 dotblas innerproduct problem

Janne Sinkkonen janne.sinkkonen at gmail.com
Thu Dec 15 04:21:12 CST 2005


With Numeric 24.2 one gets the following error:

>>> innerproduct(ones((10,3),Float), ones((10,3),Float))
ldc must be >= MAX(N,1): ldc=3 N=10Parameter 14 to routine cblas_dgemm
was incorrect

It seems to be fixed by the following patch to
Packages/dotblas/dotblas/_dotblas.c :

--- _dotblas.c~ 2005-04-07 08:15:47.000000000 +0300
+++ _dotblas.c  2005-12-15 11:31:46.148482242 +0200
@@ -530,28 +530,28 @@
                  ap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],
                  1.0, (double *)ap1->data, lda,
                  (double *)ap2->data, ldb,
-                 0.0, (double *)ret->data, ldb);
+                 0.0, (double *)ret->data, ap1->dimensions[0]);
     }
     else if (typenum == PyArray_FLOAT) {
       cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans,
                  ap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],
                  1.0, (float *)ap1->data, lda,
                  (float *)ap2->data, ldb,
-                 0.0, (float *)ret->data, ldb);
+                 0.0, (float *)ret->data, ap1->dimensions[0]);
     }
     else if (typenum == PyArray_CDOUBLE) {
       cblas_zgemm(CblasRowMajor, CblasNoTrans, CblasTrans,
                  ap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],
                  oneD, (double *)ap1->data, lda,
                  (double *)ap2->data, ldb,
-                 zeroD, (double *)ret->data, ldb);
+                 zeroD, (double *)ret->data, ap1->dimensions[0]);
     }
     else if (typenum == PyArray_CFLOAT) {
       cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasTrans,
                  ap1->dimensions[0], ap2->dimensions[0], ap1->dimensions[1],
                  oneF, (float *)ap1->data, lda,
                  (float *)ap2->data, ldb,
-                 zeroF, (float *)ret->data, ldb);
+                 zeroF, (float *)ret->data, ap1->dimensions[0]);
     }
   }
   else {


--
Janne Sinkkonen, PhD
Xtract Ltd




More information about the Numpy-discussion mailing list