ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/outil/src/ot_tenseur.h
Revision: 283
Committed: Tue Sep 13 21:11:20 2011 UTC (13 years, 8 months ago) by francois
Content type: text/plain
File size: 9055 byte(s)
Log Message:
structure de l'écriture

File Contents

# User Rev Content
1 francois 283 //---------------------------------------------------------------------------
2    
3     #ifndef ot_tenseurH
4     #define ot_tenseurH
5     //---------------------------------------------------------------------------
6    
7     #ifdef WINDOWS_VERSION
8     #ifdef BUILT_DLL_OUTIL
9     #define DLLPORTOUTIL __declspec(dllexport)
10     #else
11     #define DLLPORTOUTIL __declspec(dllimport)
12     #endif
13     #else
14     #define DLLPORTOUTIL
15     #endif
16    
17    
18    
19     #include "ot_doubleprecision.h"
20     #include <vector>
21     #include <iostream>
22     #include "ot_mathematique.h"
23    
24    
25     using namespace std;
26    
27    
28     class OT_VECTEUR_4DD;
29    
30    
31     class DLLPORTOUTIL OT_TENSEUR
32     {
33    
34     public:
35     OT_TENSEUR();
36     OT_TENSEUR(int n);
37     OT_TENSEUR(int n,int m);
38     OT_TENSEUR(vector<OT_VECTEUR_4DD>&,vector<OT_VECTEUR_4DD>&);
39     OT_TENSEUR(vector<OT_VECTEUR_4DD>&);
40    
41     OT_TENSEUR(const OT_TENSEUR& ot);
42     virtual ~OT_TENSEUR();
43    
44     OT_TENSEUR& operator = (const OT_TENSEUR& ot);
45     vector<OT_VECTEUR_4DD> operator[](int i);
46     double2& operator()(int i,int j);
47     double2& operator()(int i,int j)const;
48    
49     void identite(void);
50     int Get_NbRows()const;
51     int Get_NbCols()const;
52     virtual OT_TENSEUR transpose();
53     virtual OT_TENSEUR inverse_homogene(void);
54     virtual int est_til_equivalent( OT_TENSEUR& tns);
55     virtual void get_orthogonalisation(OT_TENSEUR& a,OT_VECTEUR_4DD& d,OT_TENSEUR& v,int n,int&nrot);
56     template<class T>int existe(const vector<T>& vct,T val,int& idx);
57     friend OT_VECTEUR_4DD operator*( OT_TENSEUR& ot1, OT_VECTEUR_4DD& ot2);
58     friend OT_TENSEUR operator*( OT_TENSEUR& ot1, OT_TENSEUR& ot2);
59     friend OT_VECTEUR_3DD operator*( OT_TENSEUR& ot1, OT_VECTEUR_3DD& ot2);
60     friend OT_TENSEUR operator*( double2& coef,OT_TENSEUR& ot );
61     friend OT_TENSEUR operator*( OT_TENSEUR& ot1, double2& coef);
62     friend vector<double2> operator*( OT_TENSEUR& ot1, vector<double2>& v);
63     friend OT_TENSEUR operator+( OT_TENSEUR& ot1, OT_TENSEUR& ot2);
64     friend int operator == ( OT_TENSEUR& t1, OT_TENSEUR& t2);
65     friend std::ostream& operator<<(std::ostream& os, OT_TENSEUR& tns);
66     int listes_equivalentes(std::vector<double2>& list1,std::vector<double2>& list2,std::vector<unsigned int>& indx) ;
67     private:
68     double2* data;
69     int Dim1;
70     int Dim2;
71     } ;
72    
73    
74     DLLPORTOUTIL int operator==( OT_TENSEUR& t1, OT_TENSEUR&t2);
75     DLLPORTOUTIL std::ostream& operator<<(std::ostream& os, OT_TENSEUR& tns);
76     DLLPORTOUTIL OT_TENSEUR operator+(OT_TENSEUR& ot1,OT_TENSEUR& ot2) ;
77     DLLPORTOUTIL template<class T>int existe(const vector<T>& vct,double val,int& idx);
78     DLLPORTOUTIL template<class T>int existe(const vector<T>& vct,double2 val,int& idx);
79     DLLPORTOUTIL template<class T>int existe(const vector<int>& vct,int val,int& idx);
80     DLLPORTOUTIL OT_TENSEUR operator*( OT_TENSEUR& ot1, double2& coef);
81     DLLPORTOUTIL OT_TENSEUR operator*( double2& coef,OT_TENSEUR& ot );
82     DLLPORTOUTIL OT_TENSEUR operator*( OT_TENSEUR& ot1, OT_TENSEUR& ot2);
83     DLLPORTOUTIL vector<double2> operator*( OT_TENSEUR& ot1, vector<double2>& v);
84     #endif
85    
86    
87    
88    
89    
90    
91    
92    
93    
94    
95    
96    
97    
98    
99    
100    
101    
102    
103    
104    
105    
106    
107    
108    
109    
110    
111    
112    
113    
114    
115    
116    
117    
118    
119    
120    
121    
122    
123    
124     /*
125     template class DLLPORTOUTIL std::vector<int>;
126     template class DLLPORTOUTIL std::vector<double2>;
127     template class DLLPORTOUTIL std::vector<float>;
128     template class DLLPORTOUTIL std::vector<double22>;
129    
130     template <class T1,int Dim=3>
131     class DLLPORTOUTIL OT_TNS
132     {
133    
134     public:
135     OT_TNS();
136     OT_TNS(vector<T1>&,vector<T1>&);
137     OT_TNS(vector<T1>&);
138     OT_TNS(int n1,T1* tab);
139     OT_TNS(int n1,int n2,T1* tab1,T1* tab2);
140     OT_TNS(const OT_TNS& ot);
141     virtual ~OT_TNS();
142    
143     OT_TNS<T1,Dim>& operator = (const OT_TNS<T1,Dim>& ot);
144     vector<T1> operator[](int i);
145     T1& operator()(int i,int j);
146     T1& operator()(int i,int j)const;
147     friend OT_TNS<T1,Dim> operator+(const OT_TNS<T1,Dim>& ot1,const OT_TNS<T1,Dim>& ot2)
148     {
149     assert (ot1.nb_lgns()==ot2.nb_lgns()&&ot1.nb_cols()==ot2.nb_cols());
150     OT_TNS<T1,Dim> res;
151     for(int i=0;i<ot1.nb_lgns();i++)
152     {
153     for(int j=0;j<ot2.nb_cols();j++)
154     {
155     res(i,j)=ot1(i,j)+ot2(i,j);
156     }
157     }
158    
159     return res;
160     }
161     friend int operator == (const OT_TNS<T1,Dim>& t1,const OT_TNS<T1,Dim>&t2){ int equa=0;
162     if(t1.nb_lgns()!=t2.nb_lgns()||t1.nb_cols()!=t2.nb_cols()) return 0;
163     else {
164     for(int i=0;i<t1.nb_lgns();i++)
165     {
166     for(int j=0;j<t1.nb_cols();j++)
167     {
168     double22 val1=t1(i,j);
169     double22 val2=t1(i,j);
170     if(!(val1==val2))
171     return equa;
172     }
173    
174     }
175     }
176     equa=1;
177     return equa;
178     }
179     int nb_lgns()const;
180     int nb_cols()const;
181     int get_spcedim()const;
182     friend std::ostream& operator<<(std::ostream& os,const OT_TNS<T1,Dim>& tns){
183     for(int i=0;i<tns.nb_lgns();i++) {
184     for(int j=0;j<tns.nb_cols();j++) {
185     os<<setw(18)<<tns(i,j);
186     }
187     os<<endl;
188     }
189     return os;
190     }
191    
192     virtual int is_equivalent_at(const OT_TNS<double22,Dim>& tns);
193     virtual int existe(const vector<double22>& vct,double22 val,int& idx);
194     virtual int existe(const vector<int>& vct,int val,int& idx) ;
195     virtual int existe(const vector<double2>& vct,double2 val,int& idx) ;
196    
197     private:
198    
199     T1* t;
200     int Dim_Spce;
201     int Dim_t1;
202     int Dim_t2;
203     } ;
204    
205    
206     template class DLLPORTOUTIL OT_TNS<double2,3>;
207     template class DLLPORTOUTIL OT_TNS<double22,3>;
208     template class DLLPORTOUTIL OT_TNS<double2,4>;
209     template class DLLPORTOUTIL OT_TNS<double22,4>;
210    
211     DLLPORTOUTIL int operator==(const OT_TNS<double2,3>& t1,const OT_TNS<double2,3>&t2);
212     DLLPORTOUTIL int operator==(const OT_TNS<double22,3>& t1,const OT_TNS<double22,3>&t2);
213     DLLPORTOUTIL std::ostream& operator<<(std::ostream& os,const OT_TNS<double2,3>& tns);
214     DLLPORTOUTIL std::ostream& operator<<(std::ostream& os,const OT_TNS<double22,3>& tns);
215     DLLPORTOUTIL OT_TNS<double2,3> operator+(const OT_TNS<double2,3>& ot1,const OT_TNS<double2,3>& ot2) ;
216     DLLPORTOUTIL OT_TNS<int,3> operator+(const OT_TNS<int,3>& ot1,const OT_TNS<int,3>& ot2) ;
217     DLLPORTOUTIL OT_TNS<double22,3> operator+(const OT_TNS<double22,3>& ot1,const OT_TNS<double22,3>& ot2) ;
218     DLLPORTOUTIL OT_TNS<double2,4> operator+(const OT_TNS<double2,4>& ot1,const OT_TNS<double2,4>& ot2) ;
219     DLLPORTOUTIL OT_TNS<int,4> operator+(const OT_TNS<int,4>& ot1,const OT_TNS<int,4>& ot2) ;
220    
221     #endif */
222    
223    
224