Mercurial > hg > octave-nkf
comparison src/ov-base-mat.cc @ 3220:3deb1105fbc1
[project @ 1998-11-19 00:06:30 by jwe]
author | jwe |
---|---|
date | Thu, 19 Nov 1998 00:06:34 +0000 |
parents | 30770ba4457a |
children | d14c483b3c12 |
comparison
equal
deleted
inserted
replaced
3219:30770ba4457a | 3220:3deb1105fbc1 |
---|---|
28 #include <config.h> | 28 #include <config.h> |
29 #endif | 29 #endif |
30 | 30 |
31 #include <iostream.h> | 31 #include <iostream.h> |
32 | 32 |
33 #include "oct-obj.h" | |
33 #include "ov-base.h" | 34 #include "ov-base.h" |
34 #include "ov-base-mat.h" | 35 #include "ov-base-mat.h" |
36 | |
37 template <class MT> | |
38 octave_value | |
39 octave_base_matrix<MT>::do_index_op (const octave_value_list& idx) | |
40 { | |
41 octave_value retval; | |
42 | |
43 int len = idx.length (); | |
44 | |
45 switch (len) | |
46 { | |
47 case 2: | |
48 { | |
49 idx_vector i = idx (0).index_vector (); | |
50 idx_vector j = idx (1).index_vector (); | |
51 | |
52 retval = MT (matrix.index (i, j)); | |
53 } | |
54 break; | |
55 | |
56 case 1: | |
57 { | |
58 idx_vector i = idx (0).index_vector (); | |
59 | |
60 retval = MT (matrix.index (i)); | |
61 } | |
62 break; | |
63 | |
64 default: | |
65 { | |
66 string n = type_name (); | |
67 | |
68 error ("invalid number of indices (%d) for %s value", | |
69 len, n.c_str ()); | |
70 } | |
71 break; | |
72 } | |
73 | |
74 return retval; | |
75 } | |
76 | |
77 template <class MT> | |
78 bool | |
79 octave_base_matrix<MT>::is_true (void) const | |
80 { | |
81 bool retval = false; | |
82 | |
83 if (rows () == 0 || columns () == 0) | |
84 { | |
85 int flag = Vpropagate_empty_matrices; | |
86 | |
87 if (flag < 0) | |
88 warning ("empty matrix used in conditional expression"); | |
89 else if (flag == 0) | |
90 error ("empty matrix used in conditional expression"); | |
91 } | |
92 else | |
93 { | |
94 boolMatrix m = (matrix.all ()) . all (); | |
95 | |
96 retval = (m.rows () == 1 && m.columns () == 1 && m (0, 0) != 0.0); | |
97 } | |
98 | |
99 return retval; | |
100 } | |
35 | 101 |
36 template <class MT> | 102 template <class MT> |
37 bool | 103 bool |
38 octave_base_matrix<MT>::print_as_scalar (void) const | 104 octave_base_matrix<MT>::print_as_scalar (void) const |
39 { | 105 { |