max@0
|
1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
|
max@0
|
2 // Copyright (C) 2008-2011 Conrad Sanderson
|
max@0
|
3 // Copyright (C) 2011 Stanislav Funiak
|
max@0
|
4 //
|
max@0
|
5 // This file is part of the Armadillo C++ library.
|
max@0
|
6 // It is provided without any warranty of fitness
|
max@0
|
7 // for any purpose. You can redistribute this file
|
max@0
|
8 // and/or modify it under the terms of the GNU
|
max@0
|
9 // Lesser General Public License (LGPL) as published
|
max@0
|
10 // by the Free Software Foundation, either version 3
|
max@0
|
11 // of the License or (at your option) any later version.
|
max@0
|
12 // (see http://www.opensource.org/licenses for more info)
|
max@0
|
13
|
max@0
|
14
|
max@0
|
15 //! \addtogroup debug
|
max@0
|
16 //! @{
|
max@0
|
17
|
max@0
|
18
|
max@0
|
19
|
max@0
|
20 template<typename T>
|
max@0
|
21 inline
|
max@0
|
22 std::ostream&
|
max@0
|
23 arma_stream_err1(std::ostream* user_stream)
|
max@0
|
24 {
|
max@0
|
25 static std::ostream* stream_err1 = &(ARMA_DEFAULT_OSTREAM);
|
max@0
|
26
|
max@0
|
27 if(user_stream != NULL)
|
max@0
|
28 {
|
max@0
|
29 stream_err1 = user_stream;
|
max@0
|
30 }
|
max@0
|
31
|
max@0
|
32 return *stream_err1;
|
max@0
|
33 }
|
max@0
|
34
|
max@0
|
35
|
max@0
|
36
|
max@0
|
37 template<typename T>
|
max@0
|
38 inline
|
max@0
|
39 std::ostream&
|
max@0
|
40 arma_stream_err2(std::ostream* user_stream)
|
max@0
|
41 {
|
max@0
|
42 static std::ostream* stream_err2 = &(ARMA_DEFAULT_OSTREAM);
|
max@0
|
43
|
max@0
|
44 if(user_stream != NULL)
|
max@0
|
45 {
|
max@0
|
46 stream_err2 = user_stream;
|
max@0
|
47 }
|
max@0
|
48
|
max@0
|
49 return *stream_err2;
|
max@0
|
50 }
|
max@0
|
51
|
max@0
|
52
|
max@0
|
53
|
max@0
|
54 inline
|
max@0
|
55 void
|
max@0
|
56 set_stream_err1(std::ostream& user_stream)
|
max@0
|
57 {
|
max@0
|
58 arma_stream_err1<char>(&user_stream);
|
max@0
|
59 }
|
max@0
|
60
|
max@0
|
61
|
max@0
|
62
|
max@0
|
63 inline
|
max@0
|
64 void
|
max@0
|
65 set_stream_err2(std::ostream& user_stream)
|
max@0
|
66 {
|
max@0
|
67 arma_stream_err2<char>(&user_stream);
|
max@0
|
68 }
|
max@0
|
69
|
max@0
|
70
|
max@0
|
71
|
max@0
|
72 inline
|
max@0
|
73 std::ostream&
|
max@0
|
74 get_stream_err1()
|
max@0
|
75 {
|
max@0
|
76 return arma_stream_err1<char>(NULL);
|
max@0
|
77 }
|
max@0
|
78
|
max@0
|
79
|
max@0
|
80
|
max@0
|
81 inline
|
max@0
|
82 std::ostream&
|
max@0
|
83 get_stream_err2()
|
max@0
|
84 {
|
max@0
|
85 return arma_stream_err2<char>(NULL);
|
max@0
|
86 }
|
max@0
|
87
|
max@0
|
88
|
max@0
|
89
|
max@0
|
90 //
|
max@0
|
91 // arma_stop
|
max@0
|
92
|
max@0
|
93 //! print a message to get_stream_err1() and/or throw a logic_error exception
|
max@0
|
94 template<typename T1>
|
max@0
|
95 inline
|
max@0
|
96 void
|
max@0
|
97 arma_cold
|
max@0
|
98 arma_stop(const T1& x)
|
max@0
|
99 {
|
max@0
|
100 #if defined(ARMA_PRINT_LOGIC_ERRORS)
|
max@0
|
101 {
|
max@0
|
102 std::ostream& out = get_stream_err1();
|
max@0
|
103
|
max@0
|
104 out.flush();
|
max@0
|
105
|
max@0
|
106 out << '\n';
|
max@0
|
107 out << "error: " << x << '\n';
|
max@0
|
108 out << '\n';
|
max@0
|
109 out.flush();
|
max@0
|
110 }
|
max@0
|
111 #else
|
max@0
|
112 {
|
max@0
|
113 arma_ignore(x);
|
max@0
|
114 }
|
max@0
|
115 #endif
|
max@0
|
116
|
max@0
|
117 throw std::logic_error("");
|
max@0
|
118 }
|
max@0
|
119
|
max@0
|
120
|
max@0
|
121
|
max@0
|
122 template<typename T1>
|
max@0
|
123 inline
|
max@0
|
124 void
|
max@0
|
125 arma_cold
|
max@0
|
126 arma_stop_bad_alloc(const T1& x)
|
max@0
|
127 {
|
max@0
|
128 std::ostream& out = get_stream_err1();
|
max@0
|
129
|
max@0
|
130 out.flush();
|
max@0
|
131
|
max@0
|
132 out << '\n';
|
max@0
|
133 out << "error: " << x << '\n';
|
max@0
|
134 out << '\n';
|
max@0
|
135 out.flush();
|
max@0
|
136
|
max@0
|
137 throw std::bad_alloc();
|
max@0
|
138 }
|
max@0
|
139
|
max@0
|
140
|
max@0
|
141
|
max@0
|
142 //
|
max@0
|
143 // arma_bad
|
max@0
|
144
|
max@0
|
145 //! print a message to get_stream_err2() and/or throw a run-time error exception
|
max@0
|
146 template<typename T1>
|
max@0
|
147 inline
|
max@0
|
148 void
|
max@0
|
149 arma_cold
|
max@0
|
150 arma_bad(const T1& x, const bool hurl = true)
|
max@0
|
151 {
|
max@0
|
152 #if defined(ARMA_PRINT_RUNTIME_ERRORS)
|
max@0
|
153 {
|
max@0
|
154 std::ostream& out = get_stream_err2();
|
max@0
|
155
|
max@0
|
156 out.flush();
|
max@0
|
157
|
max@0
|
158 out << '\n';
|
max@0
|
159 out << "error: " << x << '\n';
|
max@0
|
160 out << '\n';
|
max@0
|
161 out.flush();
|
max@0
|
162 }
|
max@0
|
163 #else
|
max@0
|
164 {
|
max@0
|
165 arma_ignore(x);
|
max@0
|
166 }
|
max@0
|
167 #endif
|
max@0
|
168
|
max@0
|
169 if(hurl == true)
|
max@0
|
170 {
|
max@0
|
171 throw std::runtime_error("");
|
max@0
|
172 }
|
max@0
|
173 }
|
max@0
|
174
|
max@0
|
175
|
max@0
|
176
|
max@0
|
177 //
|
max@0
|
178 // arma_print
|
max@0
|
179
|
max@0
|
180
|
max@0
|
181 inline
|
max@0
|
182 void
|
max@0
|
183 arma_cold
|
max@0
|
184 arma_print()
|
max@0
|
185 {
|
max@0
|
186 get_stream_err1() << std::endl;
|
max@0
|
187 }
|
max@0
|
188
|
max@0
|
189
|
max@0
|
190 template<typename T1>
|
max@0
|
191 inline
|
max@0
|
192 void
|
max@0
|
193 arma_cold
|
max@0
|
194 arma_print(const T1& x)
|
max@0
|
195 {
|
max@0
|
196 get_stream_err1() << x << std::endl;
|
max@0
|
197 }
|
max@0
|
198
|
max@0
|
199
|
max@0
|
200
|
max@0
|
201 template<typename T1, typename T2>
|
max@0
|
202 inline
|
max@0
|
203 void
|
max@0
|
204 arma_cold
|
max@0
|
205 arma_print(const T1& x, const T2& y)
|
max@0
|
206 {
|
max@0
|
207 get_stream_err1() << x << y << std::endl;
|
max@0
|
208 }
|
max@0
|
209
|
max@0
|
210
|
max@0
|
211
|
max@0
|
212 template<typename T1, typename T2, typename T3>
|
max@0
|
213 inline
|
max@0
|
214 void
|
max@0
|
215 arma_cold
|
max@0
|
216 arma_print(const T1& x, const T2& y, const T3& z)
|
max@0
|
217 {
|
max@0
|
218 get_stream_err1() << x << y << z << std::endl;
|
max@0
|
219 }
|
max@0
|
220
|
max@0
|
221
|
max@0
|
222
|
max@0
|
223
|
max@0
|
224
|
max@0
|
225
|
max@0
|
226 //
|
max@0
|
227 // arma_sigprint
|
max@0
|
228
|
max@0
|
229 //! print a message the the log stream with a preceding @ character.
|
max@0
|
230 //! by default the log stream is cout.
|
max@0
|
231 //! used for printing the signature of a function
|
max@0
|
232 //! (see the arma_extra_debug_sigprint macro)
|
max@0
|
233 inline
|
max@0
|
234 void
|
max@0
|
235 arma_sigprint(const char* x)
|
max@0
|
236 {
|
max@0
|
237 get_stream_err1() << "@ " << x;
|
max@0
|
238 }
|
max@0
|
239
|
max@0
|
240
|
max@0
|
241
|
max@0
|
242 //
|
max@0
|
243 // arma_bktprint
|
max@0
|
244
|
max@0
|
245
|
max@0
|
246 inline
|
max@0
|
247 void
|
max@0
|
248 arma_bktprint()
|
max@0
|
249 {
|
max@0
|
250 get_stream_err1() << std::endl;
|
max@0
|
251 }
|
max@0
|
252
|
max@0
|
253
|
max@0
|
254 template<typename T1>
|
max@0
|
255 inline
|
max@0
|
256 void
|
max@0
|
257 arma_bktprint(const T1& x)
|
max@0
|
258 {
|
max@0
|
259 get_stream_err1() << " [" << x << ']' << std::endl;
|
max@0
|
260 }
|
max@0
|
261
|
max@0
|
262
|
max@0
|
263
|
max@0
|
264 template<typename T1, typename T2>
|
max@0
|
265 inline
|
max@0
|
266 void
|
max@0
|
267 arma_bktprint(const T1& x, const T2& y)
|
max@0
|
268 {
|
max@0
|
269 get_stream_err1() << " [" << x << y << ']' << std::endl;
|
max@0
|
270 }
|
max@0
|
271
|
max@0
|
272
|
max@0
|
273
|
max@0
|
274
|
max@0
|
275
|
max@0
|
276
|
max@0
|
277 //
|
max@0
|
278 // arma_thisprint
|
max@0
|
279
|
max@0
|
280 inline
|
max@0
|
281 void
|
max@0
|
282 arma_thisprint(const void* this_ptr)
|
max@0
|
283 {
|
max@0
|
284 get_stream_err1() << " [this = " << this_ptr << ']' << std::endl;
|
max@0
|
285 }
|
max@0
|
286
|
max@0
|
287
|
max@0
|
288
|
max@0
|
289 //
|
max@0
|
290 // arma_warn
|
max@0
|
291
|
max@0
|
292
|
max@0
|
293 //! print a message to the warn stream
|
max@0
|
294 template<typename T1>
|
max@0
|
295 inline
|
max@0
|
296 void
|
max@0
|
297 arma_cold
|
max@0
|
298 arma_warn(const bool state, const T1& x)
|
max@0
|
299 {
|
max@0
|
300 if(state==true)
|
max@0
|
301 {
|
max@0
|
302 get_stream_err2() << x << std::endl;
|
max@0
|
303 }
|
max@0
|
304 }
|
max@0
|
305
|
max@0
|
306
|
max@0
|
307 template<typename T1, typename T2>
|
max@0
|
308 inline
|
max@0
|
309 void
|
max@0
|
310 arma_cold
|
max@0
|
311 arma_warn(const bool state, const T1& x, const T2& y)
|
max@0
|
312 {
|
max@0
|
313 if(state==true)
|
max@0
|
314 {
|
max@0
|
315 get_stream_err2() << x << y << std::endl;
|
max@0
|
316 }
|
max@0
|
317 }
|
max@0
|
318
|
max@0
|
319
|
max@0
|
320 template<typename T1, typename T2, typename T3>
|
max@0
|
321 inline
|
max@0
|
322 void
|
max@0
|
323 arma_cold
|
max@0
|
324 arma_warn(const bool state, const T1& x, const T2& y, const T3& z)
|
max@0
|
325 {
|
max@0
|
326 if(state==true)
|
max@0
|
327 {
|
max@0
|
328 get_stream_err2() << x << y << z << std::endl;
|
max@0
|
329 }
|
max@0
|
330 }
|
max@0
|
331
|
max@0
|
332
|
max@0
|
333
|
max@0
|
334 //
|
max@0
|
335 // arma_check
|
max@0
|
336
|
max@0
|
337 //! if state is true, abort program
|
max@0
|
338 template<typename T1>
|
max@0
|
339 inline
|
max@0
|
340 void
|
max@0
|
341 arma_hot
|
max@0
|
342 arma_check(const bool state, const T1& x)
|
max@0
|
343 {
|
max@0
|
344 if(state==true)
|
max@0
|
345 {
|
max@0
|
346 arma_stop(arma_boost::str_wrapper(x));
|
max@0
|
347 }
|
max@0
|
348 }
|
max@0
|
349
|
max@0
|
350
|
max@0
|
351 template<typename T1, typename T2>
|
max@0
|
352 inline
|
max@0
|
353 void
|
max@0
|
354 arma_hot
|
max@0
|
355 arma_check(const bool state, const T1& x, const T2& y)
|
max@0
|
356 {
|
max@0
|
357 if(state==true)
|
max@0
|
358 {
|
max@0
|
359 arma_stop( std::string(x) + std::string(y) );
|
max@0
|
360 }
|
max@0
|
361 }
|
max@0
|
362
|
max@0
|
363
|
max@0
|
364 template<typename T1>
|
max@0
|
365 inline
|
max@0
|
366 void
|
max@0
|
367 arma_hot
|
max@0
|
368 arma_check_bad_alloc(const bool state, const T1& x)
|
max@0
|
369 {
|
max@0
|
370 if(state==true)
|
max@0
|
371 {
|
max@0
|
372 arma_stop_bad_alloc(x);
|
max@0
|
373 }
|
max@0
|
374 }
|
max@0
|
375
|
max@0
|
376
|
max@0
|
377
|
max@0
|
378 //
|
max@0
|
379 // arma_set_error
|
max@0
|
380
|
max@0
|
381
|
max@0
|
382 arma_inline
|
max@0
|
383 void
|
max@0
|
384 arma_hot
|
max@0
|
385 arma_set_error(bool& err_state, char*& err_msg, const bool expression, const char* message)
|
max@0
|
386 {
|
max@0
|
387 if(expression == true)
|
max@0
|
388 {
|
max@0
|
389 err_state = true;
|
max@0
|
390 err_msg = const_cast<char*>(message);
|
max@0
|
391 }
|
max@0
|
392 }
|
max@0
|
393
|
max@0
|
394
|
max@0
|
395
|
max@0
|
396
|
max@0
|
397 //
|
max@0
|
398 // functions for generating strings indicating size errors
|
max@0
|
399
|
max@0
|
400 inline
|
max@0
|
401 std::string
|
max@0
|
402 arma_cold
|
max@0
|
403 arma_incompat_size_string(const uword A_n_rows, const uword A_n_cols, const uword B_n_rows, const uword B_n_cols, const char* x)
|
max@0
|
404 {
|
max@0
|
405 std::stringstream tmp;
|
max@0
|
406
|
max@0
|
407 tmp << x << ": incompatible matrix dimensions: " << A_n_rows << 'x' << A_n_cols << " and " << B_n_rows << 'x' << B_n_cols;
|
max@0
|
408
|
max@0
|
409 return tmp.str();
|
max@0
|
410 }
|
max@0
|
411
|
max@0
|
412
|
max@0
|
413
|
max@0
|
414 inline
|
max@0
|
415 arma_cold
|
max@0
|
416 std::string
|
max@0
|
417 arma_incompat_size_string(const uword A_n_rows, const uword A_n_cols, const uword A_n_slices, const uword B_n_rows, const uword B_n_cols, const uword B_n_slices, const char* x)
|
max@0
|
418 {
|
max@0
|
419 std::stringstream tmp;
|
max@0
|
420
|
max@0
|
421 tmp << x << ": incompatible cube dimensions: " << A_n_rows << 'x' << A_n_cols << 'x' << A_n_slices << " and " << B_n_rows << 'x' << B_n_cols << 'x' << B_n_slices;
|
max@0
|
422
|
max@0
|
423 return tmp.str();
|
max@0
|
424 }
|
max@0
|
425
|
max@0
|
426
|
max@0
|
427
|
max@0
|
428 template<typename eT>
|
max@0
|
429 inline
|
max@0
|
430 arma_cold
|
max@0
|
431 std::string
|
max@0
|
432 arma_incompat_size_string(const subview_cube<eT>& Q, const Mat<eT>& A, const char* x)
|
max@0
|
433 {
|
max@0
|
434 std::stringstream tmp;
|
max@0
|
435
|
max@0
|
436 tmp << x
|
max@0
|
437 << ": interpreting matrix as cube with dimenensions: "
|
max@0
|
438 << A.n_rows << 'x' << A.n_cols << 'x' << 1
|
max@0
|
439 << " or "
|
max@0
|
440 << A.n_rows << 'x' << 1 << 'x' << A.n_cols
|
max@0
|
441 << " or "
|
max@0
|
442 << 1 << 'x' << A.n_rows << 'x' << A.n_cols
|
max@0
|
443 << " is incompatible with cube dimensions: "
|
max@0
|
444 << Q.n_rows << 'x' << Q.n_cols << 'x' << Q.n_slices;
|
max@0
|
445
|
max@0
|
446 return tmp.str();
|
max@0
|
447 }
|
max@0
|
448
|
max@0
|
449
|
max@0
|
450
|
max@0
|
451 //
|
max@0
|
452 // functions for checking whether two matrices have the same dimensions
|
max@0
|
453
|
max@0
|
454
|
max@0
|
455
|
max@0
|
456 inline
|
max@0
|
457 void
|
max@0
|
458 arma_hot
|
max@0
|
459 arma_assert_same_size(const uword A_n_rows, const uword A_n_cols, const uword B_n_rows, const uword B_n_cols, const char* x)
|
max@0
|
460 {
|
max@0
|
461 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
462 {
|
max@0
|
463 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
464 }
|
max@0
|
465 }
|
max@0
|
466
|
max@0
|
467
|
max@0
|
468
|
max@0
|
469 //! stop if given matrices have different sizes
|
max@0
|
470 template<typename eT1, typename eT2>
|
max@0
|
471 inline
|
max@0
|
472 void
|
max@0
|
473 arma_hot
|
max@0
|
474 arma_assert_same_size(const Mat<eT1>& A, const Mat<eT2>& B, const char* x)
|
max@0
|
475 {
|
max@0
|
476 const uword A_n_rows = A.n_rows;
|
max@0
|
477 const uword A_n_cols = A.n_cols;
|
max@0
|
478
|
max@0
|
479 const uword B_n_rows = B.n_rows;
|
max@0
|
480 const uword B_n_cols = B.n_cols;
|
max@0
|
481
|
max@0
|
482 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
483 {
|
max@0
|
484 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
485 }
|
max@0
|
486 }
|
max@0
|
487
|
max@0
|
488
|
max@0
|
489
|
max@0
|
490 //! stop if given proxies have different sizes
|
max@0
|
491 template<typename eT1, typename eT2>
|
max@0
|
492 inline
|
max@0
|
493 void
|
max@0
|
494 arma_hot
|
max@0
|
495 arma_assert_same_size(const Proxy<eT1>& A, const Proxy<eT2>& B, const char* x)
|
max@0
|
496 {
|
max@0
|
497 const uword A_n_rows = A.get_n_rows();
|
max@0
|
498 const uword A_n_cols = A.get_n_cols();
|
max@0
|
499
|
max@0
|
500 const uword B_n_rows = B.get_n_rows();
|
max@0
|
501 const uword B_n_cols = B.get_n_cols();
|
max@0
|
502
|
max@0
|
503 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
504 {
|
max@0
|
505 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
506 }
|
max@0
|
507 }
|
max@0
|
508
|
max@0
|
509
|
max@0
|
510
|
max@0
|
511 template<typename eT1, typename eT2>
|
max@0
|
512 inline
|
max@0
|
513 void
|
max@0
|
514 arma_hot
|
max@0
|
515 arma_assert_same_size(const subview<eT1>& A, const subview<eT2>& B, const char* x)
|
max@0
|
516 {
|
max@0
|
517 const uword A_n_rows = A.n_rows;
|
max@0
|
518 const uword A_n_cols = A.n_cols;
|
max@0
|
519
|
max@0
|
520 const uword B_n_rows = B.n_rows;
|
max@0
|
521 const uword B_n_cols = B.n_cols;
|
max@0
|
522
|
max@0
|
523 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
524 {
|
max@0
|
525 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
526 }
|
max@0
|
527 }
|
max@0
|
528
|
max@0
|
529
|
max@0
|
530
|
max@0
|
531 template<typename eT1, typename eT2>
|
max@0
|
532 inline
|
max@0
|
533 void
|
max@0
|
534 arma_hot
|
max@0
|
535 arma_assert_same_size(const Mat<eT1>& A, const subview<eT2>& B, const char* x)
|
max@0
|
536 {
|
max@0
|
537 const uword A_n_rows = A.n_rows;
|
max@0
|
538 const uword A_n_cols = A.n_cols;
|
max@0
|
539
|
max@0
|
540 const uword B_n_rows = B.n_rows;
|
max@0
|
541 const uword B_n_cols = B.n_cols;
|
max@0
|
542
|
max@0
|
543 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
544 {
|
max@0
|
545 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
546 }
|
max@0
|
547 }
|
max@0
|
548
|
max@0
|
549
|
max@0
|
550
|
max@0
|
551 template<typename eT1, typename eT2>
|
max@0
|
552 inline
|
max@0
|
553 void
|
max@0
|
554 arma_hot
|
max@0
|
555 arma_assert_same_size(const subview<eT1>& A, const Mat<eT2>& B, const char* x)
|
max@0
|
556 {
|
max@0
|
557 const uword A_n_rows = A.n_rows;
|
max@0
|
558 const uword A_n_cols = A.n_cols;
|
max@0
|
559
|
max@0
|
560 const uword B_n_rows = B.n_rows;
|
max@0
|
561 const uword B_n_cols = B.n_cols;
|
max@0
|
562
|
max@0
|
563 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
564 {
|
max@0
|
565 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
566 }
|
max@0
|
567 }
|
max@0
|
568
|
max@0
|
569
|
max@0
|
570
|
max@0
|
571 template<typename eT1, typename eT2>
|
max@0
|
572 inline
|
max@0
|
573 void
|
max@0
|
574 arma_hot
|
max@0
|
575 arma_assert_same_size(const Mat<eT1>& A, const Proxy<eT2>& B, const char* x)
|
max@0
|
576 {
|
max@0
|
577 const uword A_n_rows = A.n_rows;
|
max@0
|
578 const uword A_n_cols = A.n_cols;
|
max@0
|
579
|
max@0
|
580 const uword B_n_rows = B.get_n_rows();
|
max@0
|
581 const uword B_n_cols = B.get_n_cols();
|
max@0
|
582
|
max@0
|
583 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
584 {
|
max@0
|
585 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
586 }
|
max@0
|
587 }
|
max@0
|
588
|
max@0
|
589
|
max@0
|
590
|
max@0
|
591 template<typename eT1, typename eT2>
|
max@0
|
592 inline
|
max@0
|
593 void
|
max@0
|
594 arma_hot
|
max@0
|
595 arma_assert_same_size(const Proxy<eT1>& A, const Mat<eT2>& B, const char* x)
|
max@0
|
596 {
|
max@0
|
597 const uword A_n_rows = A.get_n_rows();
|
max@0
|
598 const uword A_n_cols = A.get_n_cols();
|
max@0
|
599
|
max@0
|
600 const uword B_n_rows = B.n_rows;
|
max@0
|
601 const uword B_n_cols = B.n_cols;
|
max@0
|
602
|
max@0
|
603 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
604 {
|
max@0
|
605 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
606 }
|
max@0
|
607 }
|
max@0
|
608
|
max@0
|
609
|
max@0
|
610
|
max@0
|
611 template<typename eT1, typename eT2>
|
max@0
|
612 inline
|
max@0
|
613 void
|
max@0
|
614 arma_hot
|
max@0
|
615 arma_assert_same_size(const Proxy<eT1>& A, const subview<eT2>& B, const char* x)
|
max@0
|
616 {
|
max@0
|
617 const uword A_n_rows = A.get_n_rows();
|
max@0
|
618 const uword A_n_cols = A.get_n_cols();
|
max@0
|
619
|
max@0
|
620 const uword B_n_rows = B.n_rows;
|
max@0
|
621 const uword B_n_cols = B.n_cols;
|
max@0
|
622
|
max@0
|
623 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
624 {
|
max@0
|
625 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
626 }
|
max@0
|
627 }
|
max@0
|
628
|
max@0
|
629
|
max@0
|
630
|
max@0
|
631 template<typename eT1, typename eT2>
|
max@0
|
632 inline
|
max@0
|
633 void
|
max@0
|
634 arma_hot
|
max@0
|
635 arma_assert_same_size(const subview<eT1>& A, const Proxy<eT2>& B, const char* x)
|
max@0
|
636 {
|
max@0
|
637 const uword A_n_rows = A.n_rows;
|
max@0
|
638 const uword A_n_cols = A.n_cols;
|
max@0
|
639
|
max@0
|
640 const uword B_n_rows = B.get_n_rows();
|
max@0
|
641 const uword B_n_cols = B.get_n_cols();
|
max@0
|
642
|
max@0
|
643 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
|
max@0
|
644 {
|
max@0
|
645 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
646 }
|
max@0
|
647 }
|
max@0
|
648
|
max@0
|
649
|
max@0
|
650
|
max@0
|
651 //
|
max@0
|
652 // functions for checking whether two cubes have the same dimensions
|
max@0
|
653
|
max@0
|
654
|
max@0
|
655
|
max@0
|
656 inline
|
max@0
|
657 void
|
max@0
|
658 arma_hot
|
max@0
|
659 arma_assert_same_size(const uword A_n_rows, const uword A_n_cols, const uword A_n_slices, const uword B_n_rows, const uword B_n_cols, const uword B_n_slices, const char* x)
|
max@0
|
660 {
|
max@0
|
661 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) || (A_n_slices != B_n_slices) )
|
max@0
|
662 {
|
max@0
|
663 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, A_n_slices, B_n_rows, B_n_cols, B_n_slices, x) );
|
max@0
|
664 }
|
max@0
|
665 }
|
max@0
|
666
|
max@0
|
667
|
max@0
|
668
|
max@0
|
669 //! stop if given cubes have different sizes
|
max@0
|
670 template<typename eT1, typename eT2>
|
max@0
|
671 inline
|
max@0
|
672 void
|
max@0
|
673 arma_hot
|
max@0
|
674 arma_assert_same_size(const Cube<eT1>& A, const Cube<eT2>& B, const char* x)
|
max@0
|
675 {
|
max@0
|
676 if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != B.n_slices) )
|
max@0
|
677 {
|
max@0
|
678 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B.n_cols, B.n_slices, x) );
|
max@0
|
679 }
|
max@0
|
680 }
|
max@0
|
681
|
max@0
|
682
|
max@0
|
683
|
max@0
|
684 template<typename eT1, typename eT2>
|
max@0
|
685 inline
|
max@0
|
686 void
|
max@0
|
687 arma_hot
|
max@0
|
688 arma_assert_same_size(const Cube<eT1>& A, const subview_cube<eT2>& B, const char* x)
|
max@0
|
689 {
|
max@0
|
690 if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != B.n_slices) )
|
max@0
|
691 {
|
max@0
|
692 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B.n_cols, B.n_slices, x) );
|
max@0
|
693 }
|
max@0
|
694 }
|
max@0
|
695
|
max@0
|
696
|
max@0
|
697
|
max@0
|
698 template<typename eT1, typename eT2>
|
max@0
|
699 inline
|
max@0
|
700 void
|
max@0
|
701 arma_hot
|
max@0
|
702 arma_assert_same_size(const subview_cube<eT1>& A, const Cube<eT2>& B, const char* x)
|
max@0
|
703 {
|
max@0
|
704 if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != B.n_slices) )
|
max@0
|
705 {
|
max@0
|
706 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B.n_cols, B.n_slices, x) );
|
max@0
|
707 }
|
max@0
|
708 }
|
max@0
|
709
|
max@0
|
710
|
max@0
|
711
|
max@0
|
712 template<typename eT1, typename eT2>
|
max@0
|
713 inline
|
max@0
|
714 void
|
max@0
|
715 arma_hot
|
max@0
|
716 arma_assert_same_size(const subview_cube<eT1>& A, const subview_cube<eT2>& B, const char* x)
|
max@0
|
717 {
|
max@0
|
718 if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != B.n_slices))
|
max@0
|
719 {
|
max@0
|
720 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B.n_cols, B.n_slices, x) );
|
max@0
|
721 }
|
max@0
|
722 }
|
max@0
|
723
|
max@0
|
724
|
max@0
|
725
|
max@0
|
726 //! stop if given cube proxies have different sizes
|
max@0
|
727 template<typename eT1, typename eT2>
|
max@0
|
728 inline
|
max@0
|
729 void
|
max@0
|
730 arma_hot
|
max@0
|
731 arma_assert_same_size(const ProxyCube<eT1>& A, const ProxyCube<eT2>& B, const char* x)
|
max@0
|
732 {
|
max@0
|
733 const uword A_n_rows = A.get_n_rows();
|
max@0
|
734 const uword A_n_cols = A.get_n_cols();
|
max@0
|
735 const uword A_n_slices = A.get_n_slices();
|
max@0
|
736
|
max@0
|
737 const uword B_n_rows = B.get_n_rows();
|
max@0
|
738 const uword B_n_cols = B.get_n_cols();
|
max@0
|
739 const uword B_n_slices = B.get_n_slices();
|
max@0
|
740
|
max@0
|
741 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) || (A_n_slices != B_n_slices))
|
max@0
|
742 {
|
max@0
|
743 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, A_n_slices, B_n_rows, B_n_cols, B_n_slices, x) );
|
max@0
|
744 }
|
max@0
|
745 }
|
max@0
|
746
|
max@0
|
747
|
max@0
|
748
|
max@0
|
749 //
|
max@0
|
750 // functions for checking whether a cube or subcube can be interpreted as a matrix (i.e. single slice)
|
max@0
|
751
|
max@0
|
752
|
max@0
|
753
|
max@0
|
754 template<typename eT1, typename eT2>
|
max@0
|
755 inline
|
max@0
|
756 void
|
max@0
|
757 arma_hot
|
max@0
|
758 arma_assert_same_size(const Cube<eT1>& A, const Mat<eT2>& B, const char* x)
|
max@0
|
759 {
|
max@0
|
760 if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != 1) )
|
max@0
|
761 {
|
max@0
|
762 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B.n_cols, 1, x) );
|
max@0
|
763 }
|
max@0
|
764 }
|
max@0
|
765
|
max@0
|
766
|
max@0
|
767
|
max@0
|
768 template<typename eT1, typename eT2>
|
max@0
|
769 inline
|
max@0
|
770 void
|
max@0
|
771 arma_hot
|
max@0
|
772 arma_assert_same_size(const Mat<eT1>& A, const Cube<eT2>& B, const char* x)
|
max@0
|
773 {
|
max@0
|
774 if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (1 != B.n_slices) )
|
max@0
|
775 {
|
max@0
|
776 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, 1, B.n_rows, B.n_cols, B.n_slices, x) );
|
max@0
|
777 }
|
max@0
|
778 }
|
max@0
|
779
|
max@0
|
780
|
max@0
|
781
|
max@0
|
782 template<typename eT1, typename eT2>
|
max@0
|
783 inline
|
max@0
|
784 void
|
max@0
|
785 arma_hot
|
max@0
|
786 arma_assert_same_size(const subview_cube<eT1>& A, const Mat<eT2>& B, const char* x)
|
max@0
|
787 {
|
max@0
|
788 if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (A.n_slices != 1) )
|
max@0
|
789 {
|
max@0
|
790 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, A.n_slices, B.n_rows, B.n_cols, 1, x) );
|
max@0
|
791 }
|
max@0
|
792 }
|
max@0
|
793
|
max@0
|
794
|
max@0
|
795
|
max@0
|
796 template<typename eT1, typename eT2>
|
max@0
|
797 inline
|
max@0
|
798 void
|
max@0
|
799 arma_hot
|
max@0
|
800 arma_assert_same_size(const Mat<eT1>& A, const subview_cube<eT2>& B, const char* x)
|
max@0
|
801 {
|
max@0
|
802 if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) || (1 != B.n_slices) )
|
max@0
|
803 {
|
max@0
|
804 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, 1, B.n_rows, B.n_cols, B.n_slices, x) );
|
max@0
|
805 }
|
max@0
|
806 }
|
max@0
|
807
|
max@0
|
808
|
max@0
|
809
|
max@0
|
810 template<typename eT, typename T1>
|
max@0
|
811 inline
|
max@0
|
812 void
|
max@0
|
813 arma_assert_cube_as_mat(const Mat<eT>& M, const T1& Q, const char* x, const bool check_compat_size)
|
max@0
|
814 {
|
max@0
|
815 const uword Q_n_rows = Q.n_rows;
|
max@0
|
816 const uword Q_n_cols = Q.n_cols;
|
max@0
|
817 const uword Q_n_slices = Q.n_slices;
|
max@0
|
818
|
max@0
|
819 const uword M_vec_state = M.vec_state;
|
max@0
|
820
|
max@0
|
821 if(M_vec_state == 0)
|
max@0
|
822 {
|
max@0
|
823 if( ( (Q_n_rows == 1) || (Q_n_cols == 1) || (Q_n_slices == 1) ) == false )
|
max@0
|
824 {
|
max@0
|
825 std::stringstream tmp;
|
max@0
|
826
|
max@0
|
827 tmp << x
|
max@0
|
828 << ": can't interpret cube with dimensions "
|
max@0
|
829 << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
|
max@0
|
830 << " as a matrix; one of the dimensions must be 1";
|
max@0
|
831
|
max@0
|
832 arma_stop( tmp.str() );
|
max@0
|
833 }
|
max@0
|
834 }
|
max@0
|
835 else
|
max@0
|
836 {
|
max@0
|
837 if(Q_n_slices == 1)
|
max@0
|
838 {
|
max@0
|
839 if( (M_vec_state == 1) && (Q_n_cols != 1) )
|
max@0
|
840 {
|
max@0
|
841 std::stringstream tmp;
|
max@0
|
842
|
max@0
|
843 tmp << x
|
max@0
|
844 << ": can't interpret cube with dimensions "
|
max@0
|
845 << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
|
max@0
|
846 << " as a column vector";
|
max@0
|
847
|
max@0
|
848 arma_stop( tmp.str() );
|
max@0
|
849 }
|
max@0
|
850
|
max@0
|
851 if( (M_vec_state == 2) && (Q_n_rows != 1) )
|
max@0
|
852 {
|
max@0
|
853 std::stringstream tmp;
|
max@0
|
854
|
max@0
|
855 tmp << x
|
max@0
|
856 << ": can't interpret cube with dimensions "
|
max@0
|
857 << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
|
max@0
|
858 << " as a row vector";
|
max@0
|
859
|
max@0
|
860 arma_stop( tmp.str() );
|
max@0
|
861 }
|
max@0
|
862 }
|
max@0
|
863 else
|
max@0
|
864 {
|
max@0
|
865 if( (Q_n_cols != 1) && (Q_n_rows != 1) )
|
max@0
|
866 {
|
max@0
|
867 std::stringstream tmp;
|
max@0
|
868
|
max@0
|
869 tmp << x
|
max@0
|
870 << ": can't interpret cube with dimensions "
|
max@0
|
871 << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
|
max@0
|
872 << " as a vector";
|
max@0
|
873
|
max@0
|
874 arma_stop( tmp.str() );
|
max@0
|
875 }
|
max@0
|
876 }
|
max@0
|
877 }
|
max@0
|
878
|
max@0
|
879
|
max@0
|
880 if(check_compat_size == true)
|
max@0
|
881 {
|
max@0
|
882 const uword M_n_rows = M.n_rows;
|
max@0
|
883 const uword M_n_cols = M.n_cols;
|
max@0
|
884
|
max@0
|
885 if(M_vec_state == 0)
|
max@0
|
886 {
|
max@0
|
887 if(
|
max@0
|
888 (
|
max@0
|
889 ( (Q_n_rows == M_n_rows) && (Q_n_cols == M_n_cols) )
|
max@0
|
890 ||
|
max@0
|
891 ( (Q_n_rows == M_n_rows) && (Q_n_slices == M_n_cols) )
|
max@0
|
892 ||
|
max@0
|
893 ( (Q_n_cols == M_n_rows) && (Q_n_slices == M_n_cols) )
|
max@0
|
894 )
|
max@0
|
895 == false
|
max@0
|
896 )
|
max@0
|
897 {
|
max@0
|
898 std::stringstream tmp;
|
max@0
|
899
|
max@0
|
900 tmp << x
|
max@0
|
901 << ": can't interpret cube with dimenensions "
|
max@0
|
902 << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
|
max@0
|
903 << " as a matrix with dimensions "
|
max@0
|
904 << M_n_rows << 'x' << M_n_cols;
|
max@0
|
905
|
max@0
|
906 arma_stop( tmp.str() );
|
max@0
|
907 }
|
max@0
|
908 }
|
max@0
|
909 else
|
max@0
|
910 {
|
max@0
|
911 if(Q_n_slices == 1)
|
max@0
|
912 {
|
max@0
|
913 if( (M_vec_state == 1) && (Q_n_rows != M_n_rows) )
|
max@0
|
914 {
|
max@0
|
915 std::stringstream tmp;
|
max@0
|
916
|
max@0
|
917 tmp << x
|
max@0
|
918 << ": can't interpret cube with dimensions "
|
max@0
|
919 << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
|
max@0
|
920 << " as a column vector with dimensions "
|
max@0
|
921 << M_n_rows << 'x' << M_n_cols;
|
max@0
|
922
|
max@0
|
923 arma_stop( tmp.str() );
|
max@0
|
924 }
|
max@0
|
925
|
max@0
|
926 if( (M_vec_state == 2) && (Q_n_cols != M_n_cols) )
|
max@0
|
927 {
|
max@0
|
928 std::stringstream tmp;
|
max@0
|
929
|
max@0
|
930 tmp << x
|
max@0
|
931 << ": can't interpret cube with dimensions "
|
max@0
|
932 << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
|
max@0
|
933 << " as a row vector with dimensions "
|
max@0
|
934 << M_n_rows << 'x' << M_n_cols;
|
max@0
|
935
|
max@0
|
936 arma_stop( tmp.str() );
|
max@0
|
937 }
|
max@0
|
938 }
|
max@0
|
939 else
|
max@0
|
940 {
|
max@0
|
941 if( ( (M_n_cols == Q_n_slices) || (M_n_rows == Q_n_slices) ) == false )
|
max@0
|
942 {
|
max@0
|
943 std::stringstream tmp;
|
max@0
|
944
|
max@0
|
945 tmp << x
|
max@0
|
946 << ": can't interpret cube with dimensions "
|
max@0
|
947 << Q_n_rows << 'x' << Q_n_cols << 'x' << Q_n_slices
|
max@0
|
948 << " as a vector with dimensions "
|
max@0
|
949 << M_n_rows << 'x' << M_n_cols;
|
max@0
|
950
|
max@0
|
951 arma_stop( tmp.str() );
|
max@0
|
952 }
|
max@0
|
953 }
|
max@0
|
954 }
|
max@0
|
955 }
|
max@0
|
956 }
|
max@0
|
957
|
max@0
|
958
|
max@0
|
959
|
max@0
|
960 //
|
max@0
|
961 // functions for checking whether two matrices have dimensions that are compatible with the matrix multiply operation
|
max@0
|
962
|
max@0
|
963
|
max@0
|
964
|
max@0
|
965 inline
|
max@0
|
966 void
|
max@0
|
967 arma_hot
|
max@0
|
968 arma_assert_mul_size(const uword A_n_rows, const uword A_n_cols, const uword B_n_rows, const uword B_n_cols, const char* x)
|
max@0
|
969 {
|
max@0
|
970 if(A_n_cols != B_n_rows)
|
max@0
|
971 {
|
max@0
|
972 arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
|
max@0
|
973 }
|
max@0
|
974 }
|
max@0
|
975
|
max@0
|
976
|
max@0
|
977
|
max@0
|
978 //! stop if given matrices are incompatible for multiplication
|
max@0
|
979 template<typename eT1, typename eT2>
|
max@0
|
980 inline
|
max@0
|
981 void
|
max@0
|
982 arma_hot
|
max@0
|
983 arma_assert_mul_size(const Mat<eT1>& A, const Mat<eT2>& B, const char* x)
|
max@0
|
984 {
|
max@0
|
985 const uword A_n_cols = A.n_cols;
|
max@0
|
986 const uword B_n_rows = B.n_rows;
|
max@0
|
987
|
max@0
|
988 if(A_n_cols != B_n_rows)
|
max@0
|
989 {
|
max@0
|
990 arma_stop( arma_incompat_size_string(A.n_rows, A_n_cols, B_n_rows, B.n_cols, x) );
|
max@0
|
991 }
|
max@0
|
992 }
|
max@0
|
993
|
max@0
|
994
|
max@0
|
995
|
max@0
|
996 //! stop if given matrices are incompatible for multiplication
|
max@0
|
997 template<typename eT1, typename eT2>
|
max@0
|
998 inline
|
max@0
|
999 void
|
max@0
|
1000 arma_hot
|
max@0
|
1001 arma_assert_mul_size(const Mat<eT1>& A, const Mat<eT2>& B, const bool do_trans_A, const bool do_trans_B, const char* x)
|
max@0
|
1002 {
|
max@0
|
1003 const uword final_A_n_cols = (do_trans_A == false) ? A.n_cols : A.n_rows;
|
max@0
|
1004 const uword final_B_n_rows = (do_trans_B == false) ? B.n_rows : B.n_cols;
|
max@0
|
1005
|
max@0
|
1006 if(final_A_n_cols != final_B_n_rows)
|
max@0
|
1007 {
|
max@0
|
1008 const uword final_A_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols;
|
max@0
|
1009 const uword final_B_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows;
|
max@0
|
1010
|
max@0
|
1011 arma_stop( arma_incompat_size_string(final_A_n_rows, final_A_n_cols, final_B_n_rows, final_B_n_cols, x) );
|
max@0
|
1012 }
|
max@0
|
1013 }
|
max@0
|
1014
|
max@0
|
1015
|
max@0
|
1016
|
max@0
|
1017 template<typename eT1, typename eT2>
|
max@0
|
1018 inline
|
max@0
|
1019 void
|
max@0
|
1020 arma_hot
|
max@0
|
1021 arma_assert_mul_size(const Mat<eT1>& A, const subview<eT2>& B, const char* x)
|
max@0
|
1022 {
|
max@0
|
1023 if(A.n_cols != B.n_rows)
|
max@0
|
1024 {
|
max@0
|
1025 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, B.n_rows, B.n_cols, x) );
|
max@0
|
1026 }
|
max@0
|
1027 }
|
max@0
|
1028
|
max@0
|
1029
|
max@0
|
1030
|
max@0
|
1031 template<typename eT1, typename eT2>
|
max@0
|
1032 inline
|
max@0
|
1033 void
|
max@0
|
1034 arma_hot
|
max@0
|
1035 arma_assert_mul_size(const subview<eT1>& A, const Mat<eT2>& B, const char* x)
|
max@0
|
1036 {
|
max@0
|
1037 if(A.n_cols != B.n_rows)
|
max@0
|
1038 {
|
max@0
|
1039 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, B.n_rows, B.n_cols, x) );
|
max@0
|
1040 }
|
max@0
|
1041 }
|
max@0
|
1042
|
max@0
|
1043
|
max@0
|
1044
|
max@0
|
1045 template<typename eT1, typename eT2>
|
max@0
|
1046 inline
|
max@0
|
1047 void
|
max@0
|
1048 arma_hot
|
max@0
|
1049 arma_assert_mul_size(const subview<eT1>& A, const subview<eT2>& B, const char* x)
|
max@0
|
1050 {
|
max@0
|
1051 if(A.n_cols != B.n_rows)
|
max@0
|
1052 {
|
max@0
|
1053 arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, B.n_rows, B.n_cols, x) );
|
max@0
|
1054 }
|
max@0
|
1055 }
|
max@0
|
1056
|
max@0
|
1057
|
max@0
|
1058
|
max@0
|
1059 //
|
max@0
|
1060 // macros
|
max@0
|
1061
|
max@0
|
1062
|
max@0
|
1063 #define ARMA_STRING1(x) #x
|
max@0
|
1064 #define ARMA_STRING2(x) ARMA_STRING1(x)
|
max@0
|
1065 #define ARMA_FILELINE __FILE__ ": " ARMA_STRING2(__LINE__)
|
max@0
|
1066
|
max@0
|
1067
|
max@0
|
1068 #if defined (__GNUG__)
|
max@0
|
1069 #define ARMA_FNSIG __PRETTY_FUNCTION__
|
max@0
|
1070 #elif defined (_MSC_VER)
|
max@0
|
1071 #define ARMA_FNSIG __FUNCSIG__
|
max@0
|
1072 #elif defined (ARMA_USE_BOOST)
|
max@0
|
1073 #define ARMA_FNSIG BOOST_CURRENT_FUNCTION
|
max@0
|
1074 #else
|
max@0
|
1075 #define ARMA_FNSIG "(unknown)"
|
max@0
|
1076 #endif
|
max@0
|
1077
|
max@0
|
1078
|
max@0
|
1079
|
max@0
|
1080 #if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG)
|
max@0
|
1081
|
max@0
|
1082 #define arma_debug_print arma_print
|
max@0
|
1083 #define arma_debug_warn arma_warn
|
max@0
|
1084 #define arma_debug_check arma_check
|
max@0
|
1085 #define arma_debug_set_error arma_set_error
|
max@0
|
1086 #define arma_debug_assert_same_size arma_assert_same_size
|
max@0
|
1087 #define arma_debug_assert_mul_size arma_assert_mul_size
|
max@0
|
1088 #define arma_debug_assert_cube_as_mat arma_assert_cube_as_mat
|
max@0
|
1089
|
max@0
|
1090 #else
|
max@0
|
1091
|
max@0
|
1092 #undef ARMA_EXTRA_DEBUG
|
max@0
|
1093
|
max@0
|
1094 #define arma_debug_print true ? (void)0 : arma_print
|
max@0
|
1095 #define arma_debug_warn true ? (void)0 : arma_warn
|
max@0
|
1096 #define arma_debug_check true ? (void)0 : arma_check
|
max@0
|
1097 #define arma_debug_set_error true ? (void)0 : arma_set_error
|
max@0
|
1098 #define arma_debug_assert_same_size true ? (void)0 : arma_assert_same_size
|
max@0
|
1099 #define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul_size
|
max@0
|
1100 #define arma_debug_assert_cube_as_mat true ? (void)0 : arma_debug_assert_cube_as_mat
|
max@0
|
1101
|
max@0
|
1102 #endif
|
max@0
|
1103
|
max@0
|
1104
|
max@0
|
1105
|
max@0
|
1106 #if defined(ARMA_EXTRA_DEBUG)
|
max@0
|
1107
|
max@0
|
1108 #define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_bktprint
|
max@0
|
1109 #define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_thisprint
|
max@0
|
1110 #define arma_extra_debug_print arma_print
|
max@0
|
1111 #define arma_extra_debug_warn arma_warn
|
max@0
|
1112 #define arma_extra_debug_check arma_check
|
max@0
|
1113
|
max@0
|
1114 #else
|
max@0
|
1115
|
max@0
|
1116 #define arma_extra_debug_sigprint true ? (void)0 : arma_bktprint
|
max@0
|
1117 #define arma_extra_debug_sigprint_this true ? (void)0 : arma_thisprint
|
max@0
|
1118 #define arma_extra_debug_print true ? (void)0 : arma_print
|
max@0
|
1119 #define arma_extra_debug_warn true ? (void)0 : arma_warn
|
max@0
|
1120 #define arma_extra_debug_check true ? (void)0 : arma_check
|
max@0
|
1121
|
max@0
|
1122 #endif
|
max@0
|
1123
|
max@0
|
1124
|
max@0
|
1125
|
max@0
|
1126
|
max@0
|
1127 #if defined(ARMA_EXTRA_DEBUG)
|
max@0
|
1128
|
max@0
|
1129 namespace junk
|
max@0
|
1130 {
|
max@0
|
1131 class arma_first_extra_debug_message
|
max@0
|
1132 {
|
max@0
|
1133 public:
|
max@0
|
1134
|
max@0
|
1135 inline
|
max@0
|
1136 arma_cold
|
max@0
|
1137 arma_first_extra_debug_message()
|
max@0
|
1138 {
|
max@0
|
1139 union
|
max@0
|
1140 {
|
max@0
|
1141 unsigned short a;
|
max@0
|
1142 unsigned char b[sizeof(unsigned short)];
|
max@0
|
1143 } endian_test;
|
max@0
|
1144
|
max@0
|
1145 endian_test.a = 1;
|
max@0
|
1146
|
max@0
|
1147 const bool little_endian = (endian_test.b[0] == 1);
|
max@0
|
1148 const char* nickname = ARMA_VERSION_NAME;
|
max@0
|
1149
|
max@0
|
1150 std::ostream& out = get_stream_err1();
|
max@0
|
1151
|
max@0
|
1152 out << "@ ---" << '\n';
|
max@0
|
1153 out << "@ Armadillo "
|
max@0
|
1154 << arma_version::major << '.' << arma_version::minor << '.' << arma_version::patch
|
max@0
|
1155 << " (" << nickname << ")\n";
|
max@0
|
1156
|
max@0
|
1157 out << "@ arma_config::mat_prealloc = " << arma_config::mat_prealloc << " element(s)\n";
|
max@0
|
1158 out << "@ arma_config::atlas = " << arma_config::atlas << '\n';
|
max@0
|
1159 out << "@ arma_config::lapack = " << arma_config::lapack << '\n';
|
max@0
|
1160 out << "@ arma_config::blas = " << arma_config::blas << '\n';
|
max@0
|
1161 out << "@ arma_config::boost = " << arma_config::boost << '\n';
|
max@0
|
1162 out << "@ arma_config::boost_date = " << arma_config::boost_date << '\n';
|
max@0
|
1163 out << "@ arma_config::good_comp = " << arma_config::good_comp << '\n';
|
max@0
|
1164 out << "@ arma_config::extra_code = " << arma_config::extra_code << '\n';
|
max@0
|
1165 out << "@ sizeof(void*) = " << sizeof(void*) << '\n';
|
max@0
|
1166 out << "@ sizeof(uword) = " << sizeof(uword) << '\n';
|
max@0
|
1167 out << "@ sizeof(int) = " << sizeof(int) << '\n';
|
max@0
|
1168 out << "@ sizeof(long) = " << sizeof(long) << '\n';
|
max@0
|
1169 out << "@ sizeof(blas_int) = " << sizeof(blas_int) << '\n';
|
max@0
|
1170 out << "@ little_endian = " << little_endian << '\n';
|
max@0
|
1171 out << "@ ---" << std::endl;
|
max@0
|
1172 }
|
max@0
|
1173
|
max@0
|
1174 };
|
max@0
|
1175
|
max@0
|
1176 static arma_first_extra_debug_message arma_first_extra_debug_message_run;
|
max@0
|
1177 }
|
max@0
|
1178
|
max@0
|
1179 #endif
|
max@0
|
1180
|
max@0
|
1181
|
max@0
|
1182
|
max@0
|
1183 //! @}
|