Question: External Calling: mat_mult-Example

Call me stupid but I still wasn't able to run the simple example in the maple help (see http://www.maplesoft.com/support/help/view.aspx?path=Define_external ) regarding calling external, precompiled Code (in my Case: c++).

Here's what I did: I went to Visual Studio Express 08 and stored in mat_mult.cpp the following:


#include "mat_mult.h"

#include <stdexcept>

using namespace std;

namespace MathFuncs
{

    void MyMathFuncs::mat_mult( double *A, double *B, double *C, int I, int J, int K ){
      int i, j, k;
      double t;
      for( i = 0; i < I; ++i ){
        for( k = 0; k < K; ++k ) {
          t = 0.0;
          for( j = 0; j < J; ++j ){
            t += A[i*J+j] * B[j*K+k];
          }
          C[i*K+k] = t;
        }
      }
};
}

and the corresponding header-file: mat_mult.h

namespace MathFuncs
{
    class MyMathFuncs
    {
    public:
        static __declspec(dllexport) void mat_mult( double *A, double *B, double *C, int I, int J, int K );
    };
}

This went well and created a file "matrixmult.dll". Now I copied this file to my working directory.

As in the manual (see again http://www.maplesoft.com/support/help/view.aspx?path=Define_external ) I tried to load the mat_mult-Funktion with:

mat_mult := define_external('mat_mult', a::(ARRAY(1 .. i, 1 .. j, float[8])), b::(ARRAY(1 .. j, 1 .. k, float[8])), c::(ARRAY(1 .. i, 1 .. k, float[8])), i::(integer[4]), j::(integer[4]), k::(integer[4]), LIB = "matrixmult.dll");

This gives the error:

Error, external lookup of mat_mult: Given procedure not found.

(I also tried the same with 'MyMathFuncs::mat_mult' or 'MyMathFuncs.mat_mult' instead of 'mat_mult' but the same error.)

Please Wait...