comparison main/fixed/src/fixedRowVector.cc @ 9481:d84d2fea3c90 octave-forge

Re-enable compilation of fixed package
author jordigh
date Wed, 22 Feb 2012 22:07:33 +0000
parents f8d77845533f
children
comparison
equal deleted inserted replaced
9480:954f2f00d782 9481:d84d2fea3c90
38 #include "fixedRowVector.h" 38 #include "fixedRowVector.h"
39 39
40 // Fixed Point Row Vector class 40 // Fixed Point Row Vector class
41 41
42 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds) 42 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds)
43 : MArray<FixedPoint> (is.length()) 43 : MArray<FixedPoint> (dim_vector (1, is.length()))
44 { 44 {
45 if (length() != ds.length()) { 45 if (length() != ds.length()) {
46 (*current_liboctave_error_handler) ("vector size mismatch"); 46 (*current_liboctave_error_handler) ("vector size mismatch");
47 return; 47 return;
48 } 48 }
50 for (int i = 0; i < length (); i++) 50 for (int i = 0; i < length (); i++)
51 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i)); 51 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i));
52 } 52 }
53 53
54 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds) 54 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds)
55 : MArray<FixedPoint> (is.length()) 55 : MArray<FixedPoint> (dim_vector (1, is.length()))
56 { 56 {
57 if (length() != ds.length()) { 57 if (length() != ds.length()) {
58 (*current_liboctave_error_handler) ("vector size mismatch"); 58 (*current_liboctave_error_handler) ("vector size mismatch");
59 return; 59 return;
60 } 60 }
63 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i)); 63 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i));
64 } 64 }
65 65
66 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds, 66 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds,
67 const FixedRowVector& a) 67 const FixedRowVector& a)
68 : MArray<FixedPoint> (a.length()) 68 : MArray<FixedPoint> (dim_vector (1, a.length()))
69 { 69 {
70 if ((length() != is.length()) || (length() != ds.length())) { 70 if ((length() != is.length()) || (length() != ds.length())) {
71 (*current_liboctave_error_handler) ("vector size mismatch"); 71 (*current_liboctave_error_handler) ("vector size mismatch");
72 return; 72 return;
73 } 73 }
77 a.elem (i)); 77 a.elem (i));
78 } 78 }
79 79
80 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds, 80 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds,
81 const FixedRowVector& a) 81 const FixedRowVector& a)
82 : MArray<FixedPoint> (a.length()) 82 : MArray<FixedPoint> (dim_vector (1, a.length()))
83 { 83 {
84 if ((length() != is.length()) || (length() != ds.length())) { 84 if ((length() != is.length()) || (length() != ds.length())) {
85 (*current_liboctave_error_handler) ("vector size mismatch"); 85 (*current_liboctave_error_handler) ("vector size mismatch");
86 return; 86 return;
87 } 87 }
91 a.elem (i)); 91 a.elem (i));
92 } 92 }
93 93
94 FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds, 94 FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds,
95 const FixedRowVector& a) 95 const FixedRowVector& a)
96 : MArray<FixedPoint> (a.length()) 96 : MArray<FixedPoint> (dim_vector (1, a.length()))
97 { 97 {
98 for (int i = 0; i < length (); i++) 98 for (int i = 0; i < length (); i++)
99 elem (i) = FixedPoint(is, ds, a.elem (i)); 99 elem (i) = FixedPoint(is, ds, a.elem (i));
100 } 100 }
101 101
102 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds, 102 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds,
103 const RowVector& a) 103 const RowVector& a)
104 : MArray<FixedPoint> (a.length()) 104 : MArray<FixedPoint> (dim_vector (1, a.length()))
105 { 105 {
106 if ((length() != is.length()) || (length() != ds.length())) { 106 if ((length() != is.length()) || (length() != ds.length())) {
107 (*current_liboctave_error_handler) ("vector size mismatch"); 107 (*current_liboctave_error_handler) ("vector size mismatch");
108 return; 108 return;
109 } 109 }
113 a.elem (i)); 113 a.elem (i));
114 } 114 }
115 115
116 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds, 116 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds,
117 const RowVector& a) 117 const RowVector& a)
118 : MArray<FixedPoint> (a.length()) 118 : MArray<FixedPoint> (dim_vector (1, a.length()))
119 { 119 {
120 if ((length() != is.length()) || (length() != ds.length())) { 120 if ((length() != is.length()) || (length() != ds.length())) {
121 (*current_liboctave_error_handler) ("vector size mismatch"); 121 (*current_liboctave_error_handler) ("vector size mismatch");
122 return; 122 return;
123 } 123 }
127 a.elem (i)); 127 a.elem (i));
128 } 128 }
129 129
130 FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds, 130 FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds,
131 const RowVector& a) 131 const RowVector& a)
132 : MArray<FixedPoint> (a.length()) 132 : MArray<FixedPoint> (dim_vector (1, a.length()))
133 { 133 {
134 for (int i = 0; i < length (); i++) 134 for (int i = 0; i < length (); i++)
135 elem (i) = FixedPoint(is, ds, a.elem (i)); 135 elem (i) = FixedPoint(is, ds, a.elem (i));
136 } 136 }
137 137
138 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds, 138 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds,
139 const RowVector& a, const RowVector& b) 139 const RowVector& a, const RowVector& b)
140 : MArray<FixedPoint> (a.length()) 140 : MArray<FixedPoint> (dim_vector (1, a.length()))
141 { 141 {
142 if ((length() != b.length()) || (length() != is.length()) || 142 if ((length() != b.length()) || (length() != is.length()) ||
143 (length() != ds.length())) { 143 (length() != ds.length())) {
144 (*current_liboctave_error_handler) ("vector size mismatch"); 144 (*current_liboctave_error_handler) ("vector size mismatch");
145 return; 145 return;
151 (unsigned int)b.elem (i)); 151 (unsigned int)b.elem (i));
152 } 152 }
153 153
154 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds, 154 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds,
155 const RowVector& a, const RowVector& b) 155 const RowVector& a, const RowVector& b)
156 : MArray<FixedPoint> (a.length()) 156 : MArray<FixedPoint> (dim_vector (1, a.length()))
157 { 157 {
158 if ((length() != b.length()) || (length() != is.length()) || 158 if ((length() != b.length()) || (length() != is.length()) ||
159 (length() != ds.length())) { 159 (length() != ds.length())) {
160 (*current_liboctave_error_handler) ("vector size mismatch"); 160 (*current_liboctave_error_handler) ("vector size mismatch");
161 return; 161 return;
167 (unsigned int)b.elem (i)); 167 (unsigned int)b.elem (i));
168 } 168 }
169 169
170 FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds, 170 FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds,
171 const RowVector& a, const RowVector& b) 171 const RowVector& a, const RowVector& b)
172 : MArray<FixedPoint> (a.length()) 172 : MArray<FixedPoint> (dim_vector (1, a.length()))
173 { 173 {
174 if (length() != b.length()) { 174 if (length() != b.length()) {
175 (*current_liboctave_error_handler) ("vector size mismatch"); 175 (*current_liboctave_error_handler) ("vector size mismatch");
176 return; 176 return;
177 } 177 }
460 int a_len = a.length (); 460 int a_len = a.length ();
461 int b_len = b.length (); 461 int b_len = b.length ();
462 462
463 if (a_len == 1) 463 if (a_len == 1)
464 { 464 {
465 retval.resize(b_len); 465 retval.resize(b_len);
466 FixedPoint ad = a(0); 466 FixedPoint ad = a(0);
467 for (int i = 0; i < b_len; i++) 467 for (int i = 0; i < b_len; i++)
468 retval(i) = pow(ad, b(i)); 468 retval(i) = pow(ad, b(i));
469 } 469 }
470 else if (b_len == 1) 470 else if (b_len == 1)
471 { 471 {
472 retval.resize(a_len); 472 retval.resize(a_len);
473 FixedPoint bd = b(0); 473 FixedPoint bd = b(0);
474 for (int i = 0; i < a_len; i++) 474 for (int i = 0; i < a_len; i++)
475 retval(i) = pow(a(i), bd); 475 retval(i) = pow(a(i), bd);
476 } 476 }
477 else if (a_len == b_len) 477 else if (a_len == b_len)
478 { 478 {
479 retval.resize(a_len); 479 retval.resize(a_len);
480 for (int i = 0; i < a_len; i++) 480 for (int i = 0; i < a_len; i++)
481 retval(i) = pow(a(i), b(i)); 481 retval(i) = pow(a(i), b(i));
482 } 482 }
483 else 483 else
484 gripe_nonconformant ("operator .^", a_len, b_len); 484 gripe_nonconformant ("operator .^", a_len, b_len);
513 else 513 else
514 { 514 {
515 int a_nr = a.rows (); 515 int a_nr = a.rows ();
516 int a_nc = a.cols (); 516 int a_nc = a.cols ();
517 517
518 retval.resize (a_nc, FixedPoint()); 518 retval.resize (a_nc, FixedPoint());
519 if (len != 0) 519 if (len != 0)
520 for (int i = 0; i < a_nc; i++) 520 for (int i = 0; i < a_nc; i++)
521 for (int j = 0; j < a_nr; j++) 521 for (int j = 0; j < a_nr; j++)
522 retval.elem (i) += v.elem(j) * a.elem(j,i); 522 retval.elem (i) += v.elem(j) * a.elem(j,i);
523 } 523 }