00001 /* ./math/vector.h 00002 ********************************** 00003 Copyright INRIA and CEA 00004 00005 author : Guillaume ANCIAUX (anciaux@labri.fr, g.anciaux@laposte.net) 00006 00007 The LibMultiScale is a C++ parallel framework for the multiscale 00008 coupling methods dedicated to material simulations. This framework 00009 provides an API which makes it possible to program coupled simulations 00010 and integration of already existing codes. 00011 00012 This Project is done in a collaboration between INRIA Futurs Bordeaux 00013 within ScAlApplix team and CEA/DPTA Ile de France. 00014 00015 This software is governed by the CeCILL-C license under French law and 00016 abiding by the rules of distribution of free software. You can use, 00017 modify and/ or redistribute the software under the terms of the CeCILL-C 00018 license as circulated by CEA, CNRS and INRIA at the following URL 00019 "http://www.cecill.info". 00020 00021 As a counterpart to the access to the source code and rights to copy, 00022 modify and redistribute granted by the license, users are provided only 00023 with a limited warranty and the software's author, the holder of the 00024 economic rights, and the successive licensors have only limited 00025 liability. 00026 00027 In this respect, the user's attention is drawn to the risks associated 00028 with loading, using, modifying and/or developing or reproducing the 00029 software by the user in light of its specific status of free software, 00030 that may mean that it is complicated to manipulate, and that also 00031 therefore means that it is reserved for developers and experienced 00032 professionals having in-depth computer knowledge. Users are therefore 00033 encouraged to load and test the software's suitability as regards their 00034 requirements in conditions enabling the security of their systems and/or 00035 data to be ensured and, more generally, to use and operate it in the 00036 same conditions as regards security. 00037 00038 The fact that you are presently reading this means that you have had 00039 knowledge of the CeCILL-C license and that you accept its terms. 00040 ***********************************/ 00041 00042 #ifndef VECTOR 00043 #define VECTOR 00044 00045 #include <string.h> 00046 00047 00048 extern "C" { 00049 int ScaleVector(double * vector,int taille,double alpha); 00050 } 00051 00052 class Vector 00053 { 00054 public: 00055 00056 Vector(int t){ 00057 taille = t; 00058 vector = new double[t]; 00059 }; 00060 00061 ~Vector(){}; 00062 00064 double& operator()(int i){ 00065 return vector[i]; 00066 }; 00067 00069 int PrintToFile(char * f,int step=0){ 00070 FILE * file = fopen(f,"wb+"); 00071 PrintToFile(file,step); 00072 fclose(file); 00073 00074 return 0; 00075 } 00076 00078 int PrintToFile(FILE * f,int step=0){ 00079 00080 for (int i=0;i< taille;++i) 00081 { 00082 fprintf(f,"%d\t%d\t%.15e\n",i,step,vector[i]); 00083 } 00084 00085 return 0; 00086 }; 00087 00089 double * GetVector(){ 00090 return vector; 00091 }; 00092 00094 int zero(){ 00095 memset(vector,0,taille*sizeof(double)); // mise a zero 00096 return 0; 00097 } 00098 00100 void Scale(double a){ 00101 ScaleVector(vector,taille,a); 00102 } 00103 00104 protected: 00105 00107 int taille; 00109 double * vector; 00110 00111 00112 }; 00113 00114 #endif
1.5.2