polynoxy.cpp
来自「不错的国外的有限元程序代码,附带详细的manual,可以节省很多的底层工作.」· C++ 代码 · 共 55 行
CPP
55 行
// file POLYNOXY.CXX
#include "polynoxy.hxx"
#include "flotarry.hxx"
#include <stdlib.h>
PolynomialXY :: PolynomialXY (int n)
// Constructor. Creates an (X,Y) polynomial of degree n.
{
degree = n ;
coefficients = new FloatArray(++n * ++n / 2) ;
}
double PolynomialXY :: evaluatedAt (FloatArray* aPoint)
// Returns the value taken by the receiver at (x,y) = aPoint .
{
double answer,x,y,c,cx,cy ;
x = aPoint -> at(1) ;
y = aPoint -> at(2) ;
c = coefficients -> at(1) ;
answer = c ;
if (degree == 0)
return answer ;
cx = coefficients -> at(2) ;
cy = coefficients -> at(3) ;
answer += cx*x + cy*y ;
if (degree == 1)
return answer ;
printf ("(X,Y) polynomials with degree > 1 are not implemented \n") ;
exit(0) ;
return 0.;
}
void PolynomialXY :: printYourself ()
// Prints the receiver on screen.
{
printf ("Polynomial(X,Y) of degree %d \n",degree) ;
coefficients -> printYourself() ;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?