Mercurial > octave-nkf
comparison src/tc-index.cc @ 67:2876864f1fdb
[project @ 1993-08-18 00:29:09 by jwe]
(do_scalar_index): Handle two vector args of all ones.
author | jwe |
---|---|
date | Wed, 18 Aug 1993 00:29:09 +0000 |
parents | 78fd87e624cb |
children | 7849db4b6dbc |
comparison
equal
deleted
inserted
replaced
66:74d6f5fe70a1 | 67:2876864f1fdb |
---|---|
56 else if (type_tag == complex_scalar_constant) | 56 else if (type_tag == complex_scalar_constant) |
57 return tree_constant (*complex_scalar); | 57 return tree_constant (*complex_scalar); |
58 else | 58 else |
59 panic_impossible (); | 59 panic_impossible (); |
60 } | 60 } |
61 else if (nargs != 2) | 61 else |
62 { | 62 { |
63 error ("illegal number of arguments for scalar type"); | 63 int rows = 0; |
64 jump_to_top_level (); | 64 int cols = 0; |
65 } | 65 |
66 else if (args[1].is_matrix_type ()) | 66 switch (nargs) |
67 { | |
68 Matrix mi = args[1].matrix_value (); | |
69 | |
70 idx_vector i (mi, user_pref.do_fortran_indexing, ""); | |
71 | |
72 int len = i.length (); | |
73 if (len == i.ones_count ()) | |
74 { | 67 { |
75 if (type_tag == scalar_constant) | 68 case 3: |
76 { | 69 { |
77 if (user_pref.prefer_column_vectors) | 70 if (args[2].is_matrix_type ()) |
78 { | 71 { |
79 Matrix m (len, 1, scalar); | 72 Matrix mj = args[2].matrix_value (); |
80 return tree_constant (m); | 73 |
81 } | 74 idx_vector j (mj, user_pref.do_fortran_indexing, ""); |
82 else | 75 |
83 { | 76 int len = j.length (); |
84 Matrix m (1, len, scalar); | 77 if (len == j.ones_count ()) |
85 return tree_constant (m); | 78 cols = len; |
86 } | 79 } |
87 } | 80 else if (args[2].is_scalar_type () |
88 else if (type_tag == complex_scalar_constant) | 81 && NINT (args[2].double_value ()) == 1) |
89 { | 82 { |
90 if (user_pref.prefer_column_vectors) | 83 cols = 1; |
91 { | 84 } |
92 ComplexMatrix m (len, 1, *complex_scalar); | 85 else |
93 return tree_constant (m); | 86 break; |
94 } | 87 } |
95 else | 88 // Fall through... |
96 { | 89 case 2: |
97 ComplexMatrix m (1, len, *complex_scalar); | 90 { |
98 return tree_constant (m); | 91 if (args[1].is_matrix_type ()) |
99 } | 92 { |
100 } | 93 Matrix mi = args[1].matrix_value (); |
101 else | 94 |
102 panic_impossible (); | 95 idx_vector i (mi, user_pref.do_fortran_indexing, ""); |
96 | |
97 int len = i.length (); | |
98 if (len == i.ones_count ()) | |
99 rows = len; | |
100 } | |
101 else if (args[1].is_scalar_type () | |
102 && NINT (args[1].double_value ()) == 1) | |
103 { | |
104 rows = 1; | |
105 } | |
106 else | |
107 break; | |
108 | |
109 if (cols == 0) | |
110 { | |
111 if (user_pref.prefer_column_vectors) | |
112 cols = 1; | |
113 else | |
114 { | |
115 cols = rows; | |
116 rows = 1; | |
117 } | |
118 } | |
119 | |
120 if (type_tag == scalar_constant) | |
121 { | |
122 Matrix m (rows, cols, scalar); | |
123 return tree_constant (m); | |
124 } | |
125 else if (type_tag == complex_scalar_constant) | |
126 { | |
127 ComplexMatrix cm (rows, cols, *complex_scalar); | |
128 return tree_constant (cm); | |
129 } | |
130 else | |
131 panic_impossible (); | |
132 } | |
133 break; | |
134 default: | |
135 error ("illegal number of arguments for scalar type"); | |
136 jump_to_top_level (); | |
137 break; | |
103 } | 138 } |
104 } | 139 } |
105 | 140 |
106 error ("index invalid or out of range for scalar type"); | 141 error ("index invalid or out of range for scalar type"); |
107 jump_to_top_level (); | 142 jump_to_top_level (); |