00001
00002
00003
00004
00005
00006
00007 #ifndef CALC_NINTP_H
00008 #define CALC_NINTP_H
00009
00010
00011
00012
00013
00014 #include "Base.h"
00015 #include "Intp.h"
00016
00017
00018
00019
00020
00021 namespace calc {
00022
00023
00024
00025
00033
00034
00050 template <typename xType, typename yType>
00051 class NIntp:public Base {
00052
00053 public:
00054
00055
00056
00058 enum VTYPE {
00059 INDEPENDENT=0,
00060 KNOT ,
00061 DEPENDENT ,
00062 DERIVATIVE ,
00063 POLYGON ,
00064 ORDER ,
00065 DIMENSION ,
00066 HI_INDEX ,
00067 VTYPE_CNT ,
00068 };
00069
00070
00071
00090 operator const Intp<xType,yType> *const *(void) const
00091 {return (nogo?(Intp<xType,yType>**)(0):aIn);}
00092
00093
00094
00095 yType eval (const xType *vXn) throw (IntpErr);
00096 bool isBounded (const xType *vXn) const;
00097 bool update (void);
00098 bool update (const xType *const *arXn, const yType *arYn);
00099
00100 virtual const xType *const
00101 *getArrayX (enum NIntp<xType,yType>::VTYPE vType) const;
00102
00103 virtual int getCount (enum NIntp<xType,yType>::VTYPE vType) const;
00104 virtual const int *getArrayN (enum NIntp<xType,yType>::VTYPE vType) const;
00105 virtual int *copyArrayN (enum NIntp<xType,yType>::VTYPE vType, int *array) const;
00106 virtual xType **copyArrayX (enum NIntp<xType,yType>::VTYPE vType, xType **array) const;
00107 virtual yType *copyArrayY (enum NIntp<xType,yType>::VTYPE vType, yType *array) const;
00108
00123 enum Intp<xType,yType>::CTYPE getMethod(void) const {return cTyp;}
00139 bool isIncreasing(int iDimen) const
00140 {return ((iDimen<0)||(iDimen>=nDim)?false:bInc[iDimen]);}
00141
00142 protected:
00143
00144
00145
00146 NIntp(const xType *const *arXn, const yType *arYn,
00147 const int *arNn, const int *arOn, int nDimen);
00148 NIntp(const NIntp<xType,yType> &ni);
00149 ~NIntp(void);
00150
00151
00152
00153 void reducen(yType *aYm, Intp<xType,yType> **aIi, xType x0, int iDim) throw (IntpErr);
00154
00163 virtual bool specUpdate(void) {return false;}
00185 virtual yType evaln(Intp<xType,yType> **aIi, const xType *vXn, int iDim) throw (IntpErr)=0;
00186
00187
00188
00189 Intp<xType,yType> **aIn;
00190 enum Intp<xType,yType>::CTYPE cTyp;
00191 xType **aXn;
00192 int *aDa;
00193 int *aNn;
00194 int *aMn;
00195 int *aOn;
00196 bool *bInc;
00197 int nDim;
00198 int nData;
00199 int mData;
00201 private:
00202
00203
00204
00205 virtual void varInit (void);
00206
00207 bool varAlloc (const int *arNn, int nDimen);
00208 };
00209
00210
00211
00212
00214
00230 template <typename xType, typename yType>
00231 class NCube:public NIntp<xType,yType> {
00232
00233
00234
00235 using NIntp<xType,yType>::nogo;
00236 using NIntp<xType,yType>::nDim;
00237 using NIntp<xType,yType>::nData;
00238 using NIntp<xType,yType>::mData;
00239 using NIntp<xType,yType>::cTyp;
00240 using NIntp<xType,yType>::aXn;
00241 using NIntp<xType,yType>::aDa;
00242 using NIntp<xType,yType>::aNn;
00243 using NIntp<xType,yType>::aIn;
00244 using NIntp<xType,yType>::DERIVATIVE;
00245 using NIntp<xType,yType>::update;
00246 using NIntp<xType,yType>::specUpdate;
00247 using NIntp<xType,yType>::memCopy;
00248 using NIntp<xType,yType>::memSet;
00249
00250 public:
00251
00252
00253
00254 NCube(const NCube<xType,yType> &ni);
00255 NCube(const NIntp<xType,yType> &ni);
00256 ~NCube(void);
00257
00283 NCube(const xType *const *arXn, const yType *arYn, const int *arNn, int nDimen):
00284 NIntp<xType,yType>(arXn,arYn,arNn,(int*)(0),nDimen)
00285 {specInit(arYn,(EndCube<xType,yType>*)(0));}
00308 NCube(const xType *const *arXn, const yType *arYn,
00309 const int *arNn, int nDimen, const EndCube<xType,yType> *arDn):
00310 NIntp<xType,yType>(arXn,arYn,arNn,(int*)(0),nDimen) {specInit(arYn,arDn);}
00311
00312
00313
00314 virtual yType *copyArrayY (enum NIntp<xType,yType>::VTYPE vType, yType *array) const;
00315 virtual int getCount (enum NIntp<xType,yType>::VTYPE vType) const;
00316
00317 NCube<xType,yType> *reduce (NCube<xType,yType> *&nc, yType *&arYm, xType x0);
00318 EndCube<xType,yType> *copyArrayD (EndCube<xType,yType> *array) const;
00319
00332 const EndCube<xType,yType> *getArrayD(void) const {return aDn;}
00333
00334 private:
00335
00336
00337
00338 virtual void varInit (void);
00339 virtual yType evaln (Intp<xType,yType> **aIi, const xType *vXn, int iDim) throw (IntpErr);
00340
00341 bool varAlloc (const yType *arYn, const int *arNn, int nDimen,
00342 const EndCube<xType,yType> *arDn);
00343 void specInit (const yType *arYn, const EndCube<xType,yType> *arDn);
00344
00345
00346
00347 EndCube<xType,yType> *aDn;
00348 };
00349
00350
00351
00352
00354
00371 template <typename xType, typename yType>
00372 class NNurb:public NIntp<xType,yType> {
00373
00374
00375
00376 using NIntp<xType,yType>::nogo;
00377 using NIntp<xType,yType>::nDim;
00378 using NIntp<xType,yType>::nData;
00379 using NIntp<xType,yType>::mData;
00380 using NIntp<xType,yType>::cTyp;
00381 using NIntp<xType,yType>::aXn;
00382 using NIntp<xType,yType>::aDa;
00383 using NIntp<xType,yType>::aNn;
00384 using NIntp<xType,yType>::aOn;
00385 using NIntp<xType,yType>::aIn;
00386 using NIntp<xType,yType>::KNOT;
00387 using NIntp<xType,yType>::POLYGON;
00388 using NIntp<xType,yType>::update;
00389 using NIntp<xType,yType>::memCopy;
00390 using NIntp<xType,yType>::memSet;
00391
00392 public:
00393
00394
00395
00396 NNurb(const NNurb<xType,yType> &ni);
00397 NNurb(const NIntp<xType,yType> &ni);
00398 ~NNurb(void);
00399
00421 NNurb(const xType *const *arXn, const yType *arYn, const int *arNn, int nDimen):
00422 NIntp<xType,yType>(arXn,arYn,arNn,(int*)(0),nDimen) {specInit(arYn,(xType**)(0));}
00448 NNurb(const xType *const *arXn, const yType *arYn,
00449 const int *arNn, const int *arOn, int nDimen):
00450 NIntp<xType,yType>(arXn,arYn,arNn,arOn,nDimen)
00451 {specInit(arYn,(xType**)(0));}
00491 NNurb(const xType *const *arXn, const yType *arYn,
00492 const xType *const *arKn, const int *arNn, const int *arOn, int nDimen):
00493 NIntp<xType,yType>(arXn,arYn,arNn,arOn,nDimen) {specInit(arYn,arKn);}
00494
00495
00496
00497 virtual int getCount (enum NIntp<xType,yType>::VTYPE vType) const;
00498 virtual const xType *const *getArrayX (enum NIntp<xType,yType>::VTYPE vType) const;
00499 virtual const int *getArrayN (enum NIntp<xType,yType>::VTYPE vType) const;
00500 virtual xType **copyArrayX (enum NIntp<xType,yType>::VTYPE vType, xType **array) const;
00501 virtual yType *copyArrayY (enum NIntp<xType,yType>::VTYPE vType, yType *array) const;
00502 virtual int *copyArrayN (enum NIntp<xType,yType>::VTYPE vType, int *array) const;
00503
00504 NNurb<xType,yType> *reduce (NNurb<xType,yType> *&np, yType *&arYm, xType x0);
00505
00506 private:
00507
00508
00509
00510 virtual void varInit (void);
00511 virtual yType evaln (Intp<xType,yType> **aIi, const xType *vXn, int iDim) throw (IntpErr);
00512 virtual bool specUpdate (void);
00513
00514 bool varAlloc (const yType *arYn, const xType *const *arKn,
00515 const int *arNn, const int *arOn, int nDimen);
00516 void specInit (const yType *arYn, const xType *const *arKn);
00517
00518
00519
00520 xType **aKn;
00521 int *aLn;
00522 };
00523
00524
00525
00526
00528
00545 template <typename xType, typename yType>
00546 class NPoly:public NIntp<xType,yType> {
00547
00548
00549
00550 using NIntp<xType,yType>::nogo;
00551 using NIntp<xType,yType>::nDim;
00552 using NIntp<xType,yType>::mData;
00553 using NIntp<xType,yType>::cTyp;
00554 using NIntp<xType,yType>::bInc;
00555 using NIntp<xType,yType>::aXn;
00556 using NIntp<xType,yType>::aDa;
00557 using NIntp<xType,yType>::aMn;
00558 using NIntp<xType,yType>::aNn;
00559 using NIntp<xType,yType>::aOn;
00560 using NIntp<xType,yType>::aIn;
00561 using NIntp<xType,yType>::LO;
00562 using NIntp<xType,yType>::HI;
00563 using NIntp<xType,yType>::update;
00564 using NIntp<xType,yType>::memSet;
00565
00566 public:
00567
00568
00569
00570 NPoly(const NPoly<xType,yType> &ni);
00571 NPoly(const NIntp<xType,yType> &ni);
00572 ~NPoly(void);
00573
00595 NPoly(const xType *const *arXn, const yType *arYn, const int *arNn, int nDimen):
00596 NIntp<xType,yType>(arXn,arYn,arNn,(int*)(0),nDimen) {specInit(arYn);}
00622 NPoly(const xType *const *arXn, const yType *arYn,
00623 const int *arNn, const int *arOn, int nDimen):
00624 NIntp<xType,yType>(arXn,arYn,arNn,arOn,nDimen)
00625 {specInit(arYn);}
00626
00627
00628
00629 NPoly<xType,yType> *reduce (NPoly<xType,yType> *&np, yType *&arYm, xType x0);
00630
00631 private:
00632
00633
00634
00635 virtual void varInit (void);
00636 virtual yType evaln (Intp<xType,yType> **aIi, const xType *vXn, int iDim) throw (IntpErr);
00637 virtual bool specUpdate (void);
00638
00639
00640 bool varAlloc (const yType *arYn, const int *arNn, int nDimen, int nP0);
00641 void specInit (const yType *arYn);
00642
00643
00644
00645 int *nBnd[Base::BOUND_CNT];
00646 };}
00647
00648
00649
00650
00651
00652 #endif
00653
00654
00655
00656
00657
00658 #include "NIntp.cpp"
00659 #include "NCube.cpp"
00660 #include "NNurb.cpp"
00661 #include "NPoly.cpp"
00662
00663