A bug?There are no reference of temp varible MPtr!

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
docmao
Posts: 6
Joined: Wed Jan 09, 2008 6:54 pm
Location: China

A bug?There are no reference of temp varible MPtr!

Post by docmao »

In the following code, I found no reference of MPtr in anywhere of the soft.
A bug? It happened many times in other similar methods.
It seems strange because MPtr should be returned or referenced guessed from the method name.

int FullGenEigenSOE::addM(const Matrix &m, const ID &id, double fact)
{
// check for quick return
if (fact == 0.0)
return 0;

// check that m and id are of similar size
int idSize = id.Size();
if (idSize != m.noRows() && idSize != m.noCols()) {
opserr << "FullGenEigenSOE::addM() - Matrix and ID not of similar sizes\n";
return -1;
}

if (fact == 1.0) { // do not need to multiply
for (int i=0; i<idSize; i++) {
int col = id(i);
if (col < size && col >= 0) {
double *startColiPtr = M + col*size;
for (int j=0; j<idSize; j++) {
int row = id(j);
if (row <size && row >= 0) {
double *MPtr = startColiPtr + row;
*MPtr += m(j,i);
}
} // for j
}
} // for i
} else {
for (int i=0; i<idSize; i++) {
int col = id(i);
if (col < size && col >= 0) {
double *startColiPtr = M + col*size;
for (int j=0; j<idSize; j++) {
int row = id(j);
if (row <size && row >= 0) {
double *MPtr = startColiPtr + row;
*MPtr += m(j,i)*fact;
}
} // for j
}
} // for i
}

return 0;
}
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

it's there in the code:

[code]
double *MPtr = startColiPtr + row;
*MPtr += m(j,i)*fact;
[/code]
docmao
Posts: 6
Joined: Wed Jan 09, 2008 6:54 pm
Location: China

Post by docmao »

Thanks! I see.
Post Reply