Actual source code: tvecdouble.c

      1: #include "tvecdouble.h"
      2: #include "tao_general.h"
      3: #include "stdio.h"

      5: TaoVecDoubleArray::TaoVecDoubleArray(int nn):TaoVec(),n(nn){
      6:   v=new double[nn];
      7:   dallocated=1;
      8:   return;
      9: }

     11: TaoVecDoubleArray::TaoVecDoubleArray(int nn, double *dd):TaoVec(),n(nn){
     12:   v=dd;
     13:   dallocated=0;
     14:   return;
     15: }

     17: int TaoVecDoubleArray::Clone( TaoVec** tv ){

     19:   *tv = new TaoVecDoubleArray(this->n);
     20:   int info = (*tv)->CopyFrom(this);CHKERRQ(info);
     21:   return 0;
     22: }

     24: int TaoVecDoubleArray::GetArray(TaoScalar **dptr, int *nn){
     25:   if (sizeof(TaoScalar)==sizeof(double)){
     26:     *dptr=(TaoScalar*)v;
     27:     *nn=n;
     28:   }
     29:   else{
     30:     return 1;
     31:   }
     32:   return 0;
     33: }

     35: int TaoVecDoubleArray::RestoreArray(TaoScalar **dptr, int *nn){
     36:   *dptr=0;
     37:   *nn=0;
     38:   return 0;
     39: }

     41: int TaoVecDoubleArray::GetDoubles(double **dptr, int *nn){
     42:   *dptr=v;
     43:   *nn=n;
     44:   return 0;
     45: }

     47: int TaoVecDoubleArray::RestoreDoubles(double **dptr, int *nn){
     48:   *dptr=0;
     49:   *nn=0;
     50:   return 0;
     51: }

     53: int TaoVecDoubleArray::GetDimension(int *nn){
     54:   *nn=n;
     55:   return 0;
     56: }

     58: int TaoVecDoubleArray::Compatible(TaoVec *tv, TaoTruth *flag){
     59:   int nn,info;
     60:   double *dptr;
     61:   TaoVecDoubleArray* vv =  (TaoVecDoubleArray*)(tv);

     63:   info = vv->GetData(&dptr,&nn);
     64:   if (info==0 && nn == n) *flag=TAO_TRUE;
     65:   else *flag=TAO_FALSE;
     66:   return 0;
     67: }

     69: int TaoVecDoubleArray::View(){
     70:   for (int i=0;i<n;++i)
     71:     printf(" %4.2e \n ",v[i]);
     72:   return 0;
     73: }