къде ми е грешката ???
int isMatrixStrictlyPositive (double** matrix,int matrixOrder)
{
double oldDet = 0;
double currDet = 0;
double tempRes = 0;
int row = 0;
double** subMatrix;
oldDet = matrix[0][0];
if (oldDet < 0)
{
return 0;
}
for(int subMatrixOrder=2; subMatrixOrder < matrixOrder; subMatrixOrder++)
{
row = subMatrixOrder-1;
tempRes = 0;
currDet = 0;
for(int col = 0; col < subMatrixOrder; col++)
{
if(col == row) // in diagonal el. a33 expl.
{
tempRes = oldDet;
}
else
{
//allocate memory
subMatrix = (double **) malloc(subMatrixOrder * sizeof(double *)) ;
for (int s = 0 ; s < subMatrixOrder ; s++)
{
subMatrix = (double *) malloc(subMatrixOrder * sizeof(double)) ;
}
//eof allocate memory
formSubMatrix(matrix, matrixOrder, subMatrix, subMatrixOrder, row, col);
tempRes = Determinant(subMatrix, subMatrixOrder);
for (int s = 0 ; s < subMatrixOrder ; s++)
{
free(subMatrix) ;
}
free(subMatrix) ;
}
currDet = currDet + (pow(-1.0, row + col) * matrix[row][col] * tempRes);
}
oldDet = currDet;
if (currDet == 0)
{
return 0;
}
}
return 1; // Matrix is > 0
} // eof isMatrixStrictlyPositive
int main(int argc, char *argv[])
{
//int x[3][3]={{1,2,3},{4,5,6},{7,8,9}};
int matrixOrder = 4;
cout<<"matrixOrder = ";
cin>>matrixOrder;
double **matrix = Allocate2DArray< double >(matrixOrder , matrixOrder);
for(int i=0;i<matrixOrder;i++)
{
for(int j=0;j<matrixOrder;j++)
{
cout<<"enter["<<i+1<<"]["<<j+1<<"]"<<endl;
cin>>matrix[i][j];
// matrix[i][j]=i+j;
}
}
isMatrixStrictlyPositive();
if (isMatrixStrictlyPositive == 1)
{
cout << "Matrix is > 0 ";
cout << matrix;
}
else
{
cout << "Matrix is < 0 ";
}
cout<<"det matrix = "<<Determinant(matrix, matrixOrder)<<endl;