diff options
-rw-r--r-- | src/mtx_mul.c | 5 | ||||
-rw-r--r-- | src/mtx_transpose.c | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/mtx_mul.c b/src/mtx_mul.c index ef0f12b..8272d53 100644 --- a/src/mtx_mul.c +++ b/src/mtx_mul.c @@ -24,13 +24,16 @@ */ t_matrixfloat*mtx_doMultiply(int rowA, t_matrixfloat*A, int colArowB, t_matrixfloat*B, int colB){ - t_matrixfloat*result=(t_matrixfloat*)getbytes(sizeof(t_matrixfloat)*rowA*colB); + t_matrixfloat*result=0; + if(!A || !B || !rowA || !colArowB || !colB)return 0; + result=(t_matrixfloat*)getbytes(sizeof(t_matrixfloat)*rowA*colB); int r, c, n; for(r=0; r<rowA; r++){ for(c=0; c<colB; c++){ t_matrixfloat sum=0.f; for(n=0;n<colArowB; n++) sum+=A[colArowB*r+n]*B[colB*n+c]; + result[colB*r+c]=sum; } } return result; diff --git a/src/mtx_transpose.c b/src/mtx_transpose.c index 1fe2eab..ecc7722 100644 --- a/src/mtx_transpose.c +++ b/src/mtx_transpose.c @@ -18,7 +18,9 @@ static t_class *mtx_transpose_class; t_matrixfloat*mtx_doTranspose(t_matrixfloat*transposee, int row, int col){ int r,c; - t_matrixfloat*transposed=(t_matrixfloat*)getbytes(sizeof(t_matrixfloat)*row*col); + t_matrixfloat*transposed=0; + if(!transposee||!row||!col)return 0; + transposed=(t_matrixfloat*)getbytes(sizeof(t_matrixfloat)*row*col); r=row; while(r--){ c=col; |