Hi

Iam trying to use the In-built function cmatmmltf matrix multiplication in TS201

I need to pass the matix values from memory (tiger sharc internal memory) and perform

matrix multiplication and result should be stored in memory

The code is shown below

#include <Tigersharc.h>

#include <signal.h>

#include <matrix.h>

void main()

{

const complex_float *a = (complex_float *) 0x140000; /* Pointer to input matrix a[][] */

int n = 2; /* Number of rows in matrix a[][] */

int k =2; /* Number of columns in matrix a[][] */

const complex_float *b = (complex_float *) 0x140004;; /* Pointer to input matrix b[][] */

int m = 2; /* Number of columns in matrix b[][] */

complex_float *c = (complex_float *) 0x140008; /* Pointer to matrix c[][] */

cmatmmltf (a,n,k,b,m,c);

}

I need to pass a[2][2] = {1.0 1.0 and b[2][2] = { 1.0 1.0

1.0 1.0 } 1.0 1.0 }

Is the above method of using the matrix function is correct ? Becaz Iam not getting the expected result at 0x140008

Mahendran

Hi Mahendran,

There are a couple of issues with this example. You are explicitly setting the addresses at which the three matrices (a, b and c) are located in a manner that is not safe. The addresses chosen are all in data memory though all this code does is assign a value to each of the pointers; the compiler and linker have no knowledge that these addresses are intended to hold a 2x2 matrix and this will more likely than not result in the data being overwritten. If you do have a pressing need for each matrix to be in specific locations then you would need to utilize the RESOLVE facility in the Linker Description File.

Another issue is that you have specified a complex_float 2 by 2 array yet only allow for each of these arrays to be 4 32-bit words in size. A 2 by 2 array comprises of four complex_float elements, with a complex_float type consisting of a real part and imaginary part thus each array will be of size 8 words. Here is a small example similar to your example that demonstrates how the cmatmmltf function could be invoked:

#include <matrix.h>

/* define and initialize the two input arrays */

complex_float a[2][2]={{1.0, 2.0, 3.0, 4.0}, {5.0, 6.0, 7.0, 8.0}};

complex_float b[2][2]={{3.0, 3.0, 3.0, 3.0}, {4.0, 4.0, 4.0, 4.0}};

/* define the output matrix */

complex_float c[2][2];

void main()

{

/* Pointer to input matrix a[][] */

const complex_float *pa = (complex_float *) a;

/* Pointer to input matrix b[][] */

const complex_float *pb = (complex_float *) b;

/* Pointer to matrix c[][] */

complex_float *pc = (complex_float *) c;

int n = 2; /* Number of rows in a[][] */

int k = 2; /* Number of columns a[][] */

int m = 2; /* Number of columns b[][] */

cmatmmltf (pa, n, k, pb, m, pc);

}

Regards,

Andy.