CodePlexProject Hosting for Open Source Software

1

Vote
So trying to extend the library so the Matrices support an "Inverse" function I found that the Minor and Adjoint functions don't work. the reason? The indexing of the Matrices is calculating the index wrong for example:

in Matrix3F Minor() is doing:

for (int iRow = 0; iRow < 3; iRow++)

the code is accessing "this[0,0]"

but if you check the code for the indexer:

public float this[int row, int column]

public float this[int row, int column]

fixed the problem

in Matrix3F Minor() is doing:

for (int iRow = 0; iRow < 3; iRow++)

```
{
int c = 0;
if (iRow != row)
{
for (int iColumn = 0; iColumn < 3; iColumn++)
{
if (iColumn != column)
{
result[r,c] = this[iRow, iColumn];
```

the code is accessing "this[0,0]"

but if you check the code for the indexer:

public float this[int row, int column]

```
{
get
{
return this[(row-1)*3 + column-1];
}
set
{
this[(row-1)*3 + column-1 ] = value;
}
}
```

This code will produce a negative index. The indexer is expecting rows and columns starting with 1 but the Minor code is accessing the Rows and Columns starting at 0. Fixing the above code to :public float this[int row, int column]

```
{
get
{
return this[row*3 + column];
}
set
{
this[ row*3 + column ] = value;
}
}
```

fixed the problem

No files are attached

## comments