comparison src/DLD-FUNCTIONS/hess.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 a1dbe9d80eee
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 "CmplxHESS.h" 28 #include "CmplxHESS.h"
29 #include "dbleHESS.h" 29 #include "dbleHESS.h"
30 #include "fCmplxHESS.h"
31 #include "floatHESS.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"
87 { 89 {
88 gripe_square_matrix_required ("hess"); 90 gripe_square_matrix_required ("hess");
89 return retval; 91 return retval;
90 } 92 }
91 93
92 if (arg.is_real_type ()) 94 if (arg.is_single_type ())
93 { 95 {
94 Matrix tmp = arg.matrix_value (); 96 if (arg.is_real_type ())
97 {
98 FloatMatrix tmp = arg.float_matrix_value ();
95 99
96 if (! error_state) 100 if (! error_state)
97 { 101 {
98 HESS result (tmp); 102 FloatHESS result (tmp);
99 103
100 if (nargout == 0 || nargout == 1) 104 retval(1) = result.hess_matrix ();
101 {
102 retval.resize (1);
103 retval(0) = result.hess_matrix ();
104 }
105 else
106 {
107 retval.resize (2);
108 retval(0) = result.unitary_hess_matrix (); 105 retval(0) = result.unitary_hess_matrix ();
109 retval(1) = result.hess_matrix ();
110 } 106 }
111 } 107 }
112 } 108 else if (arg.is_complex_type ())
113 else if (arg.is_complex_type ()) 109 {
114 { 110 FloatComplexMatrix ctmp = arg.float_complex_matrix_value ();
115 ComplexMatrix ctmp = arg.complex_matrix_value ();
116 111
117 if (! error_state) 112 if (! error_state)
118 { 113 {
119 ComplexHESS result (ctmp); 114 FloatComplexHESS result (ctmp);
120 115
121 if (nargout == 0 || nargout == 1) 116 retval(1) = result.hess_matrix ();
122 {
123 retval.resize (1);
124 retval(0) = result.hess_matrix ();
125 }
126 else
127 {
128 retval.resize (2);
129 retval(0) = result.unitary_hess_matrix (); 117 retval(0) = result.unitary_hess_matrix ();
130 retval(1) = result.hess_matrix ();
131 } 118 }
132 } 119 }
133 } 120 }
134 else 121 else
135 { 122 {
136 gripe_wrong_type_arg ("hess", arg); 123 if (arg.is_real_type ())
124 {
125 Matrix tmp = arg.matrix_value ();
126
127 if (! error_state)
128 {
129 HESS result (tmp);
130
131 retval(1) = result.hess_matrix ();
132 retval(0) = result.unitary_hess_matrix ();
133 }
134 }
135 else if (arg.is_complex_type ())
136 {
137 ComplexMatrix ctmp = arg.complex_matrix_value ();
138
139 if (! error_state)
140 {
141 ComplexHESS result (ctmp);
142
143 retval(1) = result.hess_matrix ();
144 retval(0) = result.unitary_hess_matrix ();
145 }
146 }
147 else
148 {
149 gripe_wrong_type_arg ("hess", arg);
150 }
137 } 151 }
138 152
139 return retval; 153 return retval;
140 } 154 }
141 155