00001
00002
00003 #include "Adaptive1D.hpp"
00004
00005
00006
00007
00008 void AdaptiveB::Sub(AdaptiveB *X,AdaptiveB *Y) {
00009 assert(SameIndexSets(X)) ;
00010 assert(SameIndexSets(Y)) ;
00011 for (int l=Level0; l<=J; l++) {
00012 int *a=L[l].IS->a, *e=L[l].IS->e, n=L[l].IS->nr;
00013 double *d=L[l].d , *x=X->L[l].d , *y=Y->L[l].d ;
00014 for (int r=0;r<n;r++) for (int i=a[r];i<=e[r];i++) d[i] =x[i]-y[i] ;
00015 }
00016 }
00017
00018
00019 void AdaptiveB::Add(const double aa,AdaptiveB *X,const double bb,AdaptiveB *Y) {
00020 assert(SameIndexSets(X)) ;
00021 assert(SameIndexSets(Y)) ;
00022
00023 for (int l=Level0; l<=J; l++) {
00024 int *a=L[l].IS->a, *e=L[l].IS->e, n=L[l].IS->nr;
00025 double *d=L[l].d , *x=X->L[l].d , *y=Y->L[l].d ;
00026 for (int r=0;r<n;r++) for (int i=a[r];i<=e[r];i++) d[i] =aa*x[i]+bb*y[i];
00027 }
00028 }
00029
00030 void AdaptiveB::Add(const double aa,AdaptiveB *X,const double bb,AdaptiveB *Y,const double cc,AdaptiveB *Z) {
00031 assert(SameIndexSets(X)) ;
00032 assert(SameIndexSets(Y)) ;
00033 assert(SameIndexSets(Z)) ;
00034
00035 for (int l=Level0; l<=J; l++) {
00036 int *a=L[l].IS->a, *e=L[l].IS->e, n=L[l].IS->nr;
00037 double *d=L[l].d , *x=X->L[l].d , *y=Y->L[l].d , *z=Z->L[l].d ;
00038 for (int r=0;r<n;r++) for (int i=a[r];i<=e[r];i++) d[i] =aa*x[i]+bb*y[i]+cc*z[i] ;
00039 }
00040 }
00041
00042
00043
00044 void AdaptiveB::PPlus(const double aa,AdaptiveB *X) {
00045 assert(SameIndexSets(X)) ;
00046 for (int l=Level0; l<=J; l++) {
00047 int *a=L[l].IS->a, *e=L[l].IS->e, n=L[l].IS->nr;
00048 double *d=L[l].d , *x=X->L[l].d ;
00049 for (int r=0;r<n;r++) for (int i=a[r];i<=e[r];i++) d[i] +=aa*x[i] ;
00050 }
00051 }
00052
00053
00054 void AdaptiveB::PPlus(const double aa,AdaptiveB *X,const double bb,AdaptiveB *Y) {
00055 assert(SameIndexSets(X)) ;
00056 assert(SameIndexSets(Y)) ;
00057 for (int l=Level0; l<=J; l++) {
00058 int *a=L[l].IS->a, *e=L[l].IS->e, n=L[l].IS->nr;
00059 double *d=L[l].d , *x=X->L[l].d , *y=Y->L[l].d ;
00060 for (int r=0;r<n;r++) for (int i=a[r];i<=e[r];i++) d[i] +=aa*x[i]+bb*y[i] ;
00061 }
00062 }
00063
00064
00065
00066 void AdaptiveB::MMinus(AdaptiveB *X) {
00067 assert(SameIndexSets(X)) ;
00068 for (int l=Level0; l<=J; l++) {
00069 int *a=L[l].IS->a, *e=L[l].IS->e, n=L[l].IS->nr;
00070 double *d=L[l].d , *x=X->L[l].d ;
00071 for (int r=0;r<n;r++) for (int i=a[r];i<=e[r];i++) d[i] -=x[i] ;
00072 }
00073 }
00074
00075
00076 double AdaptiveB::InnerProd(AdaptiveB *X) {
00077 assert(SameIndexSets(X)) ;
00078 double c=0.0 ;
00079 int l ;
00080 for (l=Level0; l<=J; l++) c += L[l].IS->VecInnerProd(L[l].d , X->L[l].d) ;
00081 return c ;
00082 }
00083
00084 double AdaptiveB::MaxAbs() {
00085 double c=0.0 ;
00086 int l ;
00087 for (l=Level0; l<=J; l++) c=max(c, L[l].IS->VecMaxAbs(L[l].d)) ;
00088 return c ;
00089 }
00090
00091 double AdaptiveB::Max() {
00092 double c=-HUGE ;
00093 int l ;
00094 for (l=Level0; l<=J; l++) c=max(c, L[l].IS->VecMaxAbs(L[l].d)) ;
00095 return c ;
00096 }
00097
00098
00099
00100 void AdaptiveB::MMul(const double aa) {
00101 for (int l=Level0; l<=J; l++) L[l].IS->VecMul(L[l].d , aa) ;
00102 }
00103
00104
00105
00106 void AdaptiveB::CopyExtensions(AdaptiveB *) { ; }
00107
00108
00109 void AdaptiveB::Fill(double f) {
00110 int l ;
00111 for (l=Level0; l<=J; l++) L[l].IS->VecFill(L[l].d , f) ;
00112 }
00113
00114
00115
00116
00117 void AdaptiveGS::MMinus(AdaptiveGS *X) {
00118 assert(SameIndexSetsI(X)) ;
00119 int l ;
00120 for (l=Level0; l<=J; l++) L[l].I.VecMinus(L[l].d , X->L[l].d) ;
00121 }
00122
00123
00124 double AdaptiveGS::InnerProd(AdaptiveGS *X) {
00125 assert(SameIndexSetsI(X)) ;
00126 double c=0.0 ;
00127 int l ;
00128 for (l=Level0; l<=J; l++) c += L[l].I.VecInnerProd(L[l].d , X->L[l].d) ;
00129
00130 return c ;
00131 }
00132