Mercurial > octave
comparison src/OPERATORS/op-fs-fm.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 | |
children | 87865ed7405f |
comparison
equal
deleted
inserted
replaced
7788:45f5faba05a2 | 7789:82be108cc558 |
---|---|
1 /* | |
2 | |
3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, | |
4 2007 John W. Eaton | |
5 | |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 3 of the License, or (at your | |
11 option) any later version. | |
12 | |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with Octave; see the file COPYING. If not, see | |
20 <http://www.gnu.org/licenses/>. | |
21 | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include "gripes.h" | |
29 #include "oct-obj.h" | |
30 #include "ov.h" | |
31 #include "ov-scalar.h" | |
32 #include "ov-float.h" | |
33 #include "ov-re-mat.h" | |
34 #include "ov-flt-re-mat.h" | |
35 #include "ov-typeinfo.h" | |
36 #include "ops.h" | |
37 #include "xdiv.h" | |
38 #include "xpow.h" | |
39 | |
40 // scalar by matrix ops. | |
41 | |
42 DEFNDBINOP_OP (add, float_scalar, float_matrix, float_scalar, float_array, +) | |
43 DEFNDBINOP_OP (sub, float_scalar, float_matrix, float_scalar, float_array, -) | |
44 DEFNDBINOP_OP (mul, float_scalar, float_matrix, float_scalar, float_array, *) | |
45 | |
46 DEFBINOP (div, float_scalar, float_matrix) | |
47 { | |
48 CAST_BINOP_ARGS (const octave_float_scalar&, const octave_float_matrix&); | |
49 | |
50 FloatMatrix m1 = v1.float_matrix_value (); | |
51 FloatMatrix m2 = v2.float_matrix_value (); | |
52 MatrixType typ = v2.matrix_type (); | |
53 | |
54 FloatMatrix ret = xdiv (m1, m2, typ); | |
55 | |
56 v2.matrix_type (typ); | |
57 return ret; | |
58 } | |
59 | |
60 DEFBINOP_FN (pow, float_scalar, float_matrix, xpow) | |
61 | |
62 DEFBINOP (ldiv, float_scalar, float_matrix) | |
63 { | |
64 CAST_BINOP_ARGS (const octave_float_scalar&, const octave_float_matrix&); | |
65 | |
66 float d = v1.float_value (); | |
67 | |
68 if (d == 0.0) | |
69 gripe_divide_by_zero (); | |
70 | |
71 return octave_value (v2.float_array_value () / d); | |
72 } | |
73 | |
74 DEFNDBINOP_FN (lt, float_scalar, float_matrix, float_scalar, | |
75 float_array, mx_el_lt) | |
76 DEFNDBINOP_FN (le, float_scalar, float_matrix, float_scalar, | |
77 float_array, mx_el_le) | |
78 DEFNDBINOP_FN (eq, float_scalar, float_matrix, float_scalar, | |
79 float_array, mx_el_eq) | |
80 DEFNDBINOP_FN (ge, float_scalar, float_matrix, float_scalar, | |
81 float_array, mx_el_ge) | |
82 DEFNDBINOP_FN (gt, float_scalar, float_matrix, float_scalar, | |
83 float_array, mx_el_gt) | |
84 DEFNDBINOP_FN (ne, float_scalar, float_matrix, float_scalar, | |
85 float_array, mx_el_ne) | |
86 | |
87 DEFNDBINOP_OP (el_mul, float_scalar, float_matrix, float_scalar, | |
88 float_array, *) | |
89 DEFNDBINOP_FN (el_div, float_scalar, float_matrix, float_scalar, | |
90 float_array, x_el_div) | |
91 DEFNDBINOP_FN (el_pow, float_scalar, float_matrix, float_scalar, | |
92 float_array, elem_xpow) | |
93 | |
94 DEFBINOP (el_ldiv, float_scalar, float_matrix) | |
95 { | |
96 CAST_BINOP_ARGS (const octave_float_scalar&, const octave_float_matrix&); | |
97 | |
98 float d = v1.float_value (); | |
99 | |
100 if (d == 0.0) | |
101 gripe_divide_by_zero (); | |
102 | |
103 return octave_value (v2.float_array_value () / d); | |
104 } | |
105 | |
106 DEFNDBINOP_FN (el_and, float_scalar, float_matrix, float_scalar, | |
107 float_array, mx_el_and) | |
108 DEFNDBINOP_FN (el_or, float_scalar, float_matrix, float_scalar, | |
109 float_array, mx_el_or) | |
110 | |
111 DEFNDCATOP_FN (fs_fm, float_scalar, float_matrix, float_array, | |
112 float_array, concat) | |
113 | |
114 DEFCONV (matrix_conv, float_scalar, float_matrix) | |
115 { | |
116 CAST_CONV_ARG (const octave_float_scalar&); | |
117 | |
118 return new octave_float_matrix (v.float_matrix_value ()); | |
119 } | |
120 | |
121 void | |
122 install_fs_fm_ops (void) | |
123 { | |
124 INSTALL_BINOP (op_add, octave_float_scalar, octave_float_matrix, add); | |
125 INSTALL_BINOP (op_sub, octave_float_scalar, octave_float_matrix, sub); | |
126 INSTALL_BINOP (op_mul, octave_float_scalar, octave_float_matrix, mul); | |
127 INSTALL_BINOP (op_div, octave_float_scalar, octave_float_matrix, div); | |
128 INSTALL_BINOP (op_pow, octave_float_scalar, octave_float_matrix, pow); | |
129 INSTALL_BINOP (op_ldiv, octave_float_scalar, octave_float_matrix, ldiv); | |
130 INSTALL_BINOP (op_lt, octave_float_scalar, octave_float_matrix, lt); | |
131 INSTALL_BINOP (op_le, octave_float_scalar, octave_float_matrix, le); | |
132 INSTALL_BINOP (op_eq, octave_float_scalar, octave_float_matrix, eq); | |
133 INSTALL_BINOP (op_ge, octave_float_scalar, octave_float_matrix, ge); | |
134 INSTALL_BINOP (op_gt, octave_float_scalar, octave_float_matrix, gt); | |
135 INSTALL_BINOP (op_ne, octave_float_scalar, octave_float_matrix, ne); | |
136 INSTALL_BINOP (op_el_mul, octave_float_scalar, octave_float_matrix, el_mul); | |
137 INSTALL_BINOP (op_el_div, octave_float_scalar, octave_float_matrix, el_div); | |
138 INSTALL_BINOP (op_el_pow, octave_float_scalar, octave_float_matrix, el_pow); | |
139 INSTALL_BINOP (op_el_ldiv, octave_float_scalar, octave_float_matrix, el_ldiv); | |
140 INSTALL_BINOP (op_el_and, octave_float_scalar, octave_float_matrix, el_and); | |
141 INSTALL_BINOP (op_el_or, octave_float_scalar, octave_float_matrix, el_or); | |
142 | |
143 INSTALL_CATOP (octave_float_scalar, octave_float_matrix, fs_fm); | |
144 | |
145 INSTALL_ASSIGNCONV (octave_float_scalar, octave_float_matrix, octave_float_matrix); | |
146 INSTALL_ASSIGNCONV (octave_scalar, octave_float_matrix, octave_matrix); | |
147 | |
148 INSTALL_WIDENOP (octave_float_scalar, octave_float_matrix, matrix_conv); | |
149 } | |
150 | |
151 /* | |
152 ;;; Local Variables: *** | |
153 ;;; mode: C++ *** | |
154 ;;; End: *** | |
155 */ |