diagmtrx.cpp
来自「不错的国外的有限元程序代码,附带详细的manual,可以节省很多的底层工作.」· C++ 代码 · 共 45 行
CPP
45 行
// file DIAGMTRX.CXX
#include "diagmtrx.hxx"
void DiagonalMatrix :: checkBounds (int i,int j)
// Checks that the receiver possesses a (i,j) coefficient.
{
if (i>nRows || i<=0 || j!=i) {
printf ("error : DiagonalMatrix(%d) has no coeff (%d,%d)\n",nRows,i,j);
exit(0) ;}
}
FloatMatrix* DiagonalMatrix :: GiveCopy ()
// Returns a copy of the receiver. For consistency with method giveCopy()
// of class FloatMatrix, returns the answer as a FloatMatrix.
{
DiagonalMatrix *answer ;
double *P1,*P2 ;
int i ;
answer = new DiagonalMatrix(nRows) ;
P1 = values ;
P2 = answer->values ;
i = nRows ;
while (i--)
*P2++ = *P1++ ;
return (FloatMatrix*)answer ;
}
void DiagonalMatrix :: printYourself ()
// Prints the receiver on screen.
{
int i ;
printf ("Diagonal matrix of size %d\n",nRows) ;
for (i=0 ; i<nRows ; i++)
printf ("%f ",values[i]) ;
printf ("\n") ;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?