L
laclac01
I wanted to play around and see if I could make a simple little set of
routines that will do simple complex matrix math. I am not very far in
to but already it is crashing. I am sure I am not doing something
correctly so I was hoping someone smarter than I (meaning almost
everyone) could take a look at what I have and tell me what's wrong.
struct complexMatrix
{
float r;
float i;
};
#include<iostream.h>
#include "types.h"
void CmxAlloc(complexMatrix** mat,int rows, int cols);
void CmxFree(complexMatrix** mat);
int main()
{
complexMatrix** my;
CmxAlloc(my,10,10);
my[0][0].i=6; //<- this causes the program to crash
return 0;
}
//*******************************************************
void CmxAlloc(complexMatrix** mat, int rows, int cols)
{
mat = new complexMatrix*[rows];
for(int i = 0; i < rows; i++)
mat = new complexMatrix[cols];
}
//*******************************************************
void CmxFree(complexMatrix** mat)
{
delete [] mat;
}
routines that will do simple complex matrix math. I am not very far in
to but already it is crashing. I am sure I am not doing something
correctly so I was hoping someone smarter than I (meaning almost
everyone) could take a look at what I have and tell me what's wrong.
struct complexMatrix
{
float r;
float i;
};
#include<iostream.h>
#include "types.h"
void CmxAlloc(complexMatrix** mat,int rows, int cols);
void CmxFree(complexMatrix** mat);
int main()
{
complexMatrix** my;
CmxAlloc(my,10,10);
my[0][0].i=6; //<- this causes the program to crash
return 0;
}
//*******************************************************
void CmxAlloc(complexMatrix** mat, int rows, int cols)
{
mat = new complexMatrix*[rows];
for(int i = 0; i < rows; i++)
mat = new complexMatrix[cols];
}
//*******************************************************
void CmxFree(complexMatrix** mat)
{
delete [] mat;
}