ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/outil/src/ot_tenseur.h
Revision: 66
Committed: Wed Mar 19 16:45:26 2008 UTC (17 years, 2 months ago) by souaissa
Content type: text/plain
Original Path: magic/lib/outil/outil/src/ot_tenseur.h
File size: 6693 byte(s)
Log Message:
reorganisation des classes de vectorisation. Situation normalement final pour le doc de khaled

File Contents

# User Rev Content
1 francois 17 //---------------------------------------------------------------------------
2    
3     #ifndef ot_tenseurH
4     #define ot_tenseurH
5     //---------------------------------------------------------------------------
6    
7 souaissa 66 #ifdef WINDOWS_VERSION
8 francois 17 #ifdef BUILT_DLL_OUTIL
9 souaissa 66 #define DLLPORTOUTIL __declspec(dllexport)
10 francois 17 #else
11 souaissa 66 #define DLLPORTOUTIL __declspec(dllimport)
12 francois 17 #endif
13     #else
14 souaissa 66 #define DLLPORTOUTIL
15 francois 17 #endif
16    
17    
18 souaissa 66
19 francois 17 #include "ot_doubleprecision.h"
20 souaissa 58 #include <vector>
21     #include <iostream>
22 francois 17
23     using namespace std;
24    
25    
26    
27 souaissa 66 template class DLLPORTOUTIL std::vector<int>;
28     template class DLLPORTOUTIL std::vector<double>;
29     template class DLLPORTOUTIL std::vector<float>;
30     template class DLLPORTOUTIL std::vector<double2>;
31 souaissa 58
32    
33     template <class T1,int Dim=3>
34 souaissa 66 class DLLPORTOUTIL OT_TNS
35 souaissa 58 {
36    
37     public:
38     OT_TNS();
39     OT_TNS(vector<T1>&,vector<T1>&);
40     OT_TNS(vector<T1>&);
41     OT_TNS(int n1,T1* tab);
42     OT_TNS(int n1,int n2,T1* tab1,T1* tab2);
43     OT_TNS(const OT_TNS& ot);
44     virtual ~OT_TNS();
45    
46     OT_TNS<T1,Dim>& operator = (const OT_TNS<T1,Dim>& ot);
47     vector<T1> operator[](int i);
48     T1& operator()(int i,int j);
49     T1& operator()(int i,int j)const;
50     friend OT_TNS<T1,Dim> operator+(const OT_TNS<T1,Dim>& ot1,const OT_TNS<T1,Dim>& ot2)
51     {
52     assert (ot1.nb_lgns()==ot2.nb_lgns()&&ot1.nb_cols()==ot2.nb_cols());
53     OT_TNS<T1,Dim> res;
54     for(int i=0;i<ot1.nb_lgns();i++)
55     {
56     for(int j=0;j<ot2.nb_cols();j++)
57     {
58     res(i,j)=ot1(i,j)+ot2(i,j);
59     }
60     }
61    
62     return res;
63     }
64     friend int operator == (const OT_TNS<T1,Dim>& t1,const OT_TNS<T1,Dim>&t2){ int equa=0;
65     if(t1.nb_lgns()!=t2.nb_lgns()||t1.nb_cols()!=t2.nb_cols()) return 0;
66     else {
67     for(int i=0;i<t1.nb_lgns();i++)
68     {
69     for(int j=0;j<t1.nb_cols();j++)
70     {
71     double2 val1=t1(i,j);
72     double2 val2=t1(i,j);
73     if(!(val1==val2))
74     return equa;
75     }
76    
77     }
78     }
79     equa=1;
80     return equa;
81     }
82     int nb_lgns()const;
83     int nb_cols()const;
84     int get_spcedim()const;
85     friend std::ostream& operator<<(std::ostream& os,const OT_TNS<T1,Dim>& tns){
86     for(int i=0;i<tns.nb_lgns();i++) {
87     for(int j=0;j<tns.nb_cols();j++) {
88     os<<setw(18)<<tns(i,j);
89     }
90     os<<endl;
91     }
92     return os;
93     }
94    
95     virtual int is_equivalent_at(const OT_TNS<double2,Dim>& tns);
96     virtual int existe(const vector<double2>& vct,double2 val,int& idx);
97     virtual int existe(const vector<int>& vct,int val,int& idx) ;
98     virtual int existe(const vector<double>& vct,double val,int& idx) ;
99    
100     private:
101    
102     T1* t;
103     int Dim_Spce;
104     int Dim_t1;
105     int Dim_t2;
106     } ;
107    
108    
109 souaissa 66 template class DLLPORTOUTIL OT_TNS<double,3>;
110     template class DLLPORTOUTIL OT_TNS<double2,3>;
111     template class DLLPORTOUTIL OT_TNS<double,4>;
112     template class DLLPORTOUTIL OT_TNS<double2,4>;
113 souaissa 58
114 souaissa 66 DLLPORTOUTIL int operator==(const OT_TNS<double,3>& t1,const OT_TNS<double,3>&t2);
115     DLLPORTOUTIL int operator==(const OT_TNS<double2,3>& t1,const OT_TNS<double2,3>&t2);
116     DLLPORTOUTIL std::ostream& operator<<(std::ostream& os,const OT_TNS<double,3>& tns);
117     DLLPORTOUTIL std::ostream& operator<<(std::ostream& os,const OT_TNS<double2,3>& tns);
118     DLLPORTOUTIL OT_TNS<double,3> operator+(const OT_TNS<double,3>& ot1,const OT_TNS<double,3>& ot2) ;
119     DLLPORTOUTIL OT_TNS<int,3> operator+(const OT_TNS<int,3>& ot1,const OT_TNS<int,3>& ot2) ;
120     DLLPORTOUTIL OT_TNS<double2,3> operator+(const OT_TNS<double2,3>& ot1,const OT_TNS<double2,3>& ot2) ;
121     DLLPORTOUTIL OT_TNS<double,4> operator+(const OT_TNS<double,4>& ot1,const OT_TNS<double,4>& ot2) ;
122     DLLPORTOUTIL OT_TNS<int,4> operator+(const OT_TNS<int,4>& ot1,const OT_TNS<int,4>& ot2) ;
123 souaissa 58
124 francois 17 #endif
125 souaissa 58
126    
127