OSDN Git Service

fix build system ofmoflib1 and saisei1
[moflib/moflib.git] / moflib-1.0 / doc / html / matrix3__test_8cpp_source.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <title>MotifOfFunctionsLIBrary: /home/yasutomo/devel/moflib/src/mof/math/test/matrix3_test.cpp ソースファイル</title>
6 <link href="tabs.css" rel="stylesheet" type="text/css"/>
7 <link href="doxygen.css" rel="stylesheet" type="text/css"/>
8 </head>
9 <body>
10 <!-- 作成: Doxygen 1.6.3 -->
11 <div class="navigation" id="top">
12   <div class="tabs">
13     <ul>
14       <li><a href="index.html"><span>メインページ</span></a></li>
15       <li><a href="namespaces.html"><span>ネームスペース</span></a></li>
16       <li><a href="annotated.html"><span>クラス</span></a></li>
17       <li class="current"><a href="files.html"><span>ファイル</span></a></li>
18     </ul>
19   </div>
20   <div class="tabs">
21     <ul>
22       <li><a href="files.html"><span>ファイル一覧</span></a></li>
23       <li><a href="globals.html"><span>ファイルメンバ</span></a></li>
24     </ul>
25   </div>
26 <h1>/home/yasutomo/devel/moflib/src/mof/math/test/matrix3_test.cpp</h1><a href="matrix3__test_8cpp.html">説明を見る。</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;<a class="code" href="matrix3_8hpp.html">mof/math/matrix3.hpp</a>&gt;</span>
27 <a name="l00002"></a>00002 <span class="preprocessor">#include &lt;<a class="code" href="vector3_8hpp.html">mof/math/vector3.hpp</a>&gt;</span>
28 <a name="l00003"></a>00003 <span class="preprocessor">#include &lt;iostream&gt;</span>
29 <a name="l00004"></a>00004 <span class="preprocessor">#include &lt;sstream&gt;</span>
30 <a name="l00005"></a>00005 
31 <a name="l00006"></a><a class="code" href="matrix3__test_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">00006</a> <span class="keywordtype">int</span> <a class="code" href="matrix2__test_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>()
32 <a name="l00007"></a>00007 {
33 <a name="l00008"></a>00008     <span class="keyword">using namespace </span>mof::math;
34 <a name="l00009"></a>00009     <span class="keyword">using namespace </span>std;
35 <a name="l00010"></a>00010     <span class="keywordtype">int</span> failed_count = 0;
36 <a name="l00011"></a>00011 
37 <a name="l00012"></a>00012     {
38 <a name="l00013"></a>00013         matrix3 M;
39 <a name="l00014"></a>00014         <span class="keywordtype">bool</span> failed = <span class="keyword">false</span>;
40 <a name="l00015"></a>00015         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; 15; ++i) {
41 <a name="l00016"></a>00016             <span class="keywordflow">if</span> (M[i / 4][i % 4] != 0) failed = <span class="keyword">true</span>;
42 <a name="l00017"></a>00017         }
43 <a name="l00018"></a>00018         <span class="keywordflow">if</span> (failed || M[3][3] != 1) {
44 <a name="l00019"></a>00019             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot; default constructor makes zero matrix&quot;</span> &lt;&lt; endl;  
45 <a name="l00020"></a>00020             failed_count++;
46 <a name="l00021"></a>00021         }
47 <a name="l00022"></a>00022     }
48 <a name="l00023"></a>00023 
49 <a name="l00024"></a>00024     {
50 <a name="l00025"></a>00025         matrix3 M(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
51 <a name="l00026"></a>00026         <span class="keywordtype">bool</span> failed = <span class="keyword">false</span>;
52 <a name="l00027"></a>00027         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; 15; ++i) {
53 <a name="l00028"></a>00028             <span class="keywordflow">if</span> (M[i / 4][i % 4] != i + 1) failed = <span class="keyword">true</span>;
54 <a name="l00029"></a>00029         }
55 <a name="l00030"></a>00030         <span class="keywordflow">if</span> (failed || M[3][3] != 1) {
56 <a name="l00031"></a>00031             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot; initialize test&quot;</span> &lt;&lt; endl;    
57 <a name="l00032"></a>00032             failed_count++;
58 <a name="l00033"></a>00033         }
59 <a name="l00034"></a>00034     }
60 <a name="l00035"></a>00035 
61 <a name="l00036"></a>00036     {
62 <a name="l00037"></a>00037         <span class="keywordtype">float</span> arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
63 <a name="l00038"></a>00038         matrix3 M(arr);
64 <a name="l00039"></a>00039         <span class="keywordtype">bool</span> failed = <span class="keyword">false</span>;
65 <a name="l00040"></a>00040         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; 15; ++i) {
66 <a name="l00041"></a>00041             <span class="keywordflow">if</span> (M[i / 4][i % 4] != i + 1) failed = <span class="keyword">true</span>;
67 <a name="l00042"></a>00042         }
68 <a name="l00043"></a>00043         <span class="keywordflow">if</span> (failed || M[3][3] != 1) {
69 <a name="l00044"></a>00044             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot; initialize by array test&quot;</span> &lt;&lt; endl;   
70 <a name="l00045"></a>00045             failed_count++;
71 <a name="l00046"></a>00046         }
72 <a name="l00047"></a>00047     }
73 <a name="l00048"></a>00048 
74 <a name="l00049"></a>00049     <span class="comment">// any operations keeps the last component 1</span>
75 <a name="l00050"></a>00050     {   
76 <a name="l00051"></a>00051         matrix3 M(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
77 <a name="l00052"></a>00052         matrix3 N(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
78 <a name="l00053"></a>00053         <span class="keywordflow">if</span> (M != N) {
79 <a name="l00054"></a>00054             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot; M == N test&quot;</span> &lt;&lt; endl;    
80 <a name="l00055"></a>00055             failed_count++;
81 <a name="l00056"></a>00056         }
82 <a name="l00057"></a>00057     }
83 <a name="l00058"></a>00058     
84 <a name="l00059"></a>00059     {   
85 <a name="l00060"></a>00060         matrix3 M(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
86 <a name="l00061"></a>00061         matrix3 N(0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
87 <a name="l00062"></a>00062         <span class="keywordflow">if</span> (M == N) {
88 <a name="l00063"></a>00063             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot; M != N test&quot;</span> &lt;&lt; endl;    
89 <a name="l00064"></a>00064             failed_count++;
90 <a name="l00065"></a>00065         }
91 <a name="l00066"></a>00066     }
92 <a name="l00067"></a>00067 
93 <a name="l00068"></a>00068     {
94 <a name="l00069"></a>00069         matrix3 N1(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
95 <a name="l00070"></a>00070         matrix3 N2(29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1);
96 <a name="l00071"></a>00071         matrix3 N = N1 + N2;
97 <a name="l00072"></a>00072         matrix3 A(30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16);
98 <a name="l00073"></a>00073         <span class="keywordflow">if</span> (N != A) {
99 <a name="l00074"></a>00074             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot; addition test&quot;</span> &lt;&lt; endl;  
100 <a name="l00075"></a>00075             failed_count++;
101 <a name="l00076"></a>00076         }
102 <a name="l00077"></a>00077     }
103 <a name="l00078"></a>00078     
104 <a name="l00079"></a>00079     {
105 <a name="l00080"></a>00080         matrix3 N1(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
106 <a name="l00081"></a>00081         matrix3 N2(29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1);
107 <a name="l00082"></a>00082         matrix3 N = N1 - N2;
108 <a name="l00083"></a>00083         matrix3 A
109 <a name="l00084"></a>00084         (
110 <a name="l00085"></a>00085             -28, -25, -22, -19,
111 <a name="l00086"></a>00086             -16, -13, -10,  -7,
112 <a name="l00087"></a>00087              -4,  -1,   2,   5,
113 <a name="l00088"></a>00088               8,  11,  14  
114 <a name="l00089"></a>00089         );
115 <a name="l00090"></a>00090         <span class="keywordflow">if</span> (N != A) {
116 <a name="l00091"></a>00091             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot; subtraction test&quot;</span> &lt;&lt; endl;   
117 <a name="l00092"></a>00092             failed_count++;
118 <a name="l00093"></a>00093         }
119 <a name="l00094"></a>00094     }
120 <a name="l00095"></a>00095 
121 <a name="l00096"></a>00096     {
122 <a name="l00097"></a>00097         matrix3 N1(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, 0);
123 <a name="l00098"></a>00098         matrix3 N2(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0);
124 <a name="l00099"></a>00099         matrix3 N = N1 * N2;
125 <a name="l00100"></a>00100         matrix3 A(44, 50, 56, 66, 116, 134, 152, 178, 188, 218, 248, 290, 0, 0, 0);
126 <a name="l00101"></a>00101         <span class="keywordflow">if</span> (N != A) {
127 <a name="l00102"></a>00102             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot;Affine matrix N1 * N2 test&quot;</span> &lt;&lt; endl;  
128 <a name="l00103"></a>00103             failed_count++;
129 <a name="l00104"></a>00104         }
130 <a name="l00105"></a>00105     }
131 <a name="l00106"></a>00106     
132 <a name="l00107"></a>00107     {
133 <a name="l00108"></a>00108         matrix3 N1(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
134 <a name="l00109"></a>00109         matrix3 N2(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
135 <a name="l00110"></a>00110         matrix3 N = N1 * N2;
136 <a name="l00111"></a>00111         matrix3 A
137 <a name="l00112"></a>00112         (
138 <a name="l00113"></a>00113             0.25840f, 0.28424f, 0.31008, 0.17054f,
139 <a name="l00114"></a>00114             0.58915f, 0.65633f, 0.72351f, 0.45995f,
140 <a name="l00115"></a>00115             0.91990f, 1.02842f, 1.13695f, 0.74935f,
141 <a name="l00116"></a>00116             0.70801f, 0.81912f, 0.93023f
142 <a name="l00117"></a>00117         );
143 <a name="l00118"></a>00118         <span class="keywordflow">if</span> (N != A) {
144 <a name="l00119"></a>00119             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot;Projective matrix N1 * N2 test&quot;</span> &lt;&lt; endl;  
145 <a name="l00120"></a>00120             failed_count++;
146 <a name="l00121"></a>00121         }
147 <a name="l00122"></a>00122     }
148 <a name="l00123"></a>00123     
149 <a name="l00124"></a>00124     {
150 <a name="l00125"></a>00125         matrix3 M(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
151 <a name="l00126"></a>00126         vector3 v(1, 2, 3);
152 <a name="l00127"></a>00127         vector3 w = M * v;
153 <a name="l00128"></a>00128         vector3 a(0.20690f, 0.52874f, 0.85057f);
154 <a name="l00129"></a>00129         <span class="keywordflow">if</span> (a != w) {
155 <a name="l00130"></a>00130             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot;M * v test&quot;</span> &lt;&lt; endl;  
156 <a name="l00131"></a>00131             failed_count++;
157 <a name="l00132"></a>00132         }
158 <a name="l00133"></a>00133     }
159 <a name="l00134"></a>00134 
160 <a name="l00135"></a>00135 
161 <a name="l00136"></a>00136     {
162 <a name="l00137"></a>00137         matrix3 M(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
163 <a name="l00138"></a>00138         matrix3 N = 2 * M * 3;
164 <a name="l00139"></a>00139         matrix3 A(6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90);
165 <a name="l00140"></a>00140         <span class="keywordflow">if</span> (N != A) {
166 <a name="l00141"></a>00141             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot;s * M * s test&quot;</span> &lt;&lt; endl;  
167 <a name="l00142"></a>00142             failed_count++;
168 <a name="l00143"></a>00143         }
169 <a name="l00144"></a>00144     }
170 <a name="l00145"></a>00145     
171 <a name="l00146"></a>00146     {
172 <a name="l00147"></a>00147         matrix3 M(6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90);
173 <a name="l00148"></a>00148         matrix3 N = M / 6;
174 <a name="l00149"></a>00149         matrix3 A(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
175 <a name="l00150"></a>00150         <span class="keywordflow">if</span> (N != A) {
176 <a name="l00151"></a>00151             cerr &lt;&lt; <span class="stringliteral">&quot;Failed:&quot;</span> &lt;&lt; <span class="stringliteral">&quot;M / s test&quot;</span> &lt;&lt; endl;  
177 <a name="l00152"></a>00152             failed_count++;
178 <a name="l00153"></a>00153         }
179 <a name="l00154"></a>00154     }
180 <a name="l00155"></a>00155 
181 <a name="l00156"></a>00156     <span class="keywordflow">return</span> failed_count;
182 <a name="l00157"></a>00157 }
183 </pre></div></div>
184 <hr class="footer"/><address style="text-align: right;"><small>MotifOfFunctionsLIBraryに対してThu Aug 19 09:37:38 2010に生成されました。&nbsp;
185 <a href="http://www.doxygen.org/index.html">
186 <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
187 </body>
188 </html>