comparison src/DLD-FUNCTIONS/det.cc @ 7789:82be108cc558

First attempt at single precision tyeps * * * corrections to qrupdate single precision routines * * * prefer demotion to single over promotion to double * * * Add single precision support to log2 function * * * Trivial PROJECT file update * * * Cache optimized hermitian/transpose methods * * * Add tests for tranpose/hermitian and ChangeLog entry for new transpose code
author David Bateman <dbateman@free.fr>
date Sun, 27 Apr 2008 22:34:17 +0200
parents eb7bdde776f2
children 87865ed7405f
comparison
equal deleted inserted replaced
7788:45f5faba05a2 7789:82be108cc558
25 #include <config.h> 25 #include <config.h>
26 #endif 26 #endif
27 27
28 #include "CmplxDET.h" 28 #include "CmplxDET.h"
29 #include "dbleDET.h" 29 #include "dbleDET.h"
30 #include "fCmplxDET.h"
31 #include "floatDET.h"
30 32
31 #include "defun-dld.h" 33 #include "defun-dld.h"
32 #include "error.h" 34 #include "error.h"
33 #include "gripes.h" 35 #include "gripes.h"
34 #include "oct-obj.h" 36 #include "oct-obj.h"
73 { 75 {
74 gripe_square_matrix_required ("det"); 76 gripe_square_matrix_required ("det");
75 return retval; 77 return retval;
76 } 78 }
77 79
78 if (arg.is_real_type ()) 80
81 if (arg.is_single_type ())
79 { 82 {
80 octave_idx_type info; 83 if (arg.is_real_type ())
81 double rcond = 0.0;
82 // Always compute rcond, so we can detect numerically
83 // singular matrices.
84 if (arg.is_sparse_type ())
85 { 84 {
86 SparseMatrix m = arg.sparse_matrix_value (); 85 octave_idx_type info;
86 float rcond = 0.0;
87 // Always compute rcond, so we can detect numerically
88 // singular matrices.
89 FloatMatrix m = arg.float_matrix_value ();
87 if (! error_state) 90 if (! error_state)
88 { 91 {
89 DET det = m.determinant (info, rcond); 92 FloatDET det = m.determinant (info, rcond);
90 retval(1) = rcond; 93 retval(1) = rcond;
91 volatile double xrcond = rcond; 94 volatile float xrcond = rcond;
92 xrcond += 1.0; 95 xrcond += 1.0;
93 retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ()); 96 retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ());
94 } 97 }
95 } 98 }
96 else 99 else if (arg.is_complex_type ())
97 { 100 {
98 Matrix m = arg.matrix_value (); 101 octave_idx_type info;
102 float rcond = 0.0;
103 // Always compute rcond, so we can detect numerically
104 // singular matrices.
105 FloatComplexMatrix m = arg.float_complex_matrix_value ();
99 if (! error_state) 106 if (! error_state)
100 { 107 {
101 DET det = m.determinant (info, rcond); 108 FloatComplexDET det = m.determinant (info, rcond);
102 retval(1) = rcond; 109 retval(1) = rcond;
103 volatile double xrcond = rcond; 110 volatile float xrcond = rcond;
104 xrcond += 1.0;
105 retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ());
106 }
107 }
108 }
109 else if (arg.is_complex_type ())
110 {
111 octave_idx_type info;
112 double rcond = 0.0;
113 // Always compute rcond, so we can detect numerically
114 // singular matrices.
115 if (arg.is_sparse_type ())
116 {
117 SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
118 if (! error_state)
119 {
120 ComplexDET det = m.determinant (info, rcond);
121 retval(1) = rcond;
122 volatile double xrcond = rcond;
123 xrcond += 1.0; 111 xrcond += 1.0;
124 retval(0) = ((info == -1 || xrcond == 1.0) 112 retval(0) = ((info == -1 || xrcond == 1.0)
125 ? Complex (0.0) : det.value ()); 113 ? Complex (0.0) : det.value ());
126 } 114
127 }
128 else
129 {
130 ComplexMatrix m = arg.complex_matrix_value ();
131 if (! error_state)
132 {
133 ComplexDET det = m.determinant (info, rcond);
134 retval(1) = rcond;
135 volatile double xrcond = rcond;
136 xrcond += 1.0;
137 retval(0) = ((info == -1 || xrcond == 1.0)
138 ? Complex (0.0) : det.value ());
139
140 } 115 }
141 } 116 }
142 } 117 }
143 else 118 else
144 gripe_wrong_type_arg ("det", arg); 119 {
120 if (arg.is_real_type ())
121 {
122 octave_idx_type info;
123 double rcond = 0.0;
124 // Always compute rcond, so we can detect numerically
125 // singular matrices.
126 if (arg.is_sparse_type ())
127 {
128 SparseMatrix m = arg.sparse_matrix_value ();
129 if (! error_state)
130 {
131 DET det = m.determinant (info, rcond);
132 retval(1) = rcond;
133 volatile double xrcond = rcond;
134 xrcond += 1.0;
135 retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ());
136 }
137 }
138 else
139 {
140 Matrix m = arg.matrix_value ();
141 if (! error_state)
142 {
143 DET det = m.determinant (info, rcond);
144 retval(1) = rcond;
145 volatile double xrcond = rcond;
146 xrcond += 1.0;
147 retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ());
148 }
149 }
150 }
151 else if (arg.is_complex_type ())
152 {
153 octave_idx_type info;
154 double rcond = 0.0;
155 // Always compute rcond, so we can detect numerically
156 // singular matrices.
157 if (arg.is_sparse_type ())
158 {
159 SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
160 if (! error_state)
161 {
162 ComplexDET det = m.determinant (info, rcond);
163 retval(1) = rcond;
164 volatile double xrcond = rcond;
165 xrcond += 1.0;
166 retval(0) = ((info == -1 || xrcond == 1.0)
167 ? Complex (0.0) : det.value ());
168 }
169 }
170 else
171 {
172 ComplexMatrix m = arg.complex_matrix_value ();
173 if (! error_state)
174 {
175 ComplexDET det = m.determinant (info, rcond);
176 retval(1) = rcond;
177 volatile double xrcond = rcond;
178 xrcond += 1.0;
179 retval(0) = ((info == -1 || xrcond == 1.0)
180 ? Complex (0.0) : det.value ());
145 181
182 }
183 }
184 }
185 else
186 gripe_wrong_type_arg ("det", arg);
187 }
146 return retval; 188 return retval;
147 } 189 }
148 190
149 /* 191 /*
150 ;;; Local Variables: *** 192 ;;; Local Variables: ***