/* take the inverse of a matrix source to a matrix destination * workarray size at least (3 * n * n + 2 * n) * with n is rows is columns from source (=equal to destination) */ void XXMatrixInverse (XXMatrix *mat_dest, XXMatrix *mat_source, XXDouble *workarray) { XXDouble det; det = XXInverse(mat_dest, mat_source, workarray); /* here you could do something with the det result */ }
/* divide scalar source1 with matrix source2 to matrix destination * workarray size at least (3 * n * n + 2 * n) * with n is rows is columns from source2 (=equal to destination) */ void XXScalarMatrixDiv (XXMatrix *mat_dest, XXDouble s1, XXMatrix *mat_source2, XXDouble *workarray) { XXDouble det; XXInteger i, size; det = XXInverse(mat_dest, mat_source2, workarray); /* here you could do something with the det result */ if( det == 0.0 ) return; /* and multiply by the scalar */ size = mat_dest->rows * mat_dest->columns; for( i = 0; i < size; i++) mat_dest->mat[i] *= s1; }
/* divide matrix source1 with matrix source2 to matrix destination * workarray size at least (4 * n * n + 2 * n) * with n is rows is columns from source2 */ void XXMatrixDiv (XXMatrix *mat_dest, XXMatrix *mat_source1, XXMatrix *mat_source2, XXDouble *workarray) { XXMatrix workMatrix; XXInteger offset; XXDouble det; workMatrix.rows = mat_source2->rows; workMatrix.columns = mat_source2->columns; workMatrix.mat = workarray; offset = workMatrix.rows * workMatrix.columns; /* take the inverse and put it in our workmatrix */ det = XXInverse(&workMatrix, mat_source2, &workarray[offset]); if( det == 0.0 ) return; /* multiply source 1 with the workMatrix(=inverse(source1)) */ XXMatrixMul(mat_dest, mat_source1, &workMatrix); }