Mercurial > octave-nkf
comparison src/OPERATORS/op-fs-fs.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, 1998, 2000, 2001, 2002, 2003, 2004, 2005, | |
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-flt-re-mat.h" | |
34 #include "ov-typeinfo.h" | |
35 #include "ops.h" | |
36 #include "xdiv.h" | |
37 #include "xpow.h" | |
38 | |
39 // scalar unary ops. | |
40 | |
41 DEFUNOP_OP (not, float_scalar, !) | |
42 DEFUNOP_OP (uplus, float_scalar, /* no-op */) | |
43 DEFUNOP_OP (uminus, float_scalar, -) | |
44 DEFUNOP_OP (transpose, float_scalar, /* no-op */) | |
45 DEFUNOP_OP (hermitian, float_scalar, /* no-op */) | |
46 | |
47 DEFNCUNOP_METHOD (incr, float_scalar, increment) | |
48 DEFNCUNOP_METHOD (decr, float_scalar, decrement) | |
49 | |
50 // float by float ops. | |
51 | |
52 DEFBINOP_OP (add, float_scalar, float_scalar, +) | |
53 DEFBINOP_OP (sub, float_scalar, float_scalar, -) | |
54 DEFBINOP_OP (mul, float_scalar, float_scalar, *) | |
55 | |
56 DEFBINOP (div, float_scalar, float_scalar) | |
57 { | |
58 CAST_BINOP_ARGS (const octave_float_scalar&, const octave_float_scalar&); | |
59 | |
60 float d = v2.float_value (); | |
61 | |
62 if (d == 0.0) | |
63 gripe_divide_by_zero (); | |
64 | |
65 return octave_value (v1.float_value () / d); | |
66 } | |
67 | |
68 DEFBINOP_FN (pow, float_scalar, float_scalar, xpow) | |
69 | |
70 DEFBINOP (ldiv, float_scalar, float_scalar) | |
71 { | |
72 CAST_BINOP_ARGS (const octave_float_scalar&, const octave_float_scalar&); | |
73 | |
74 float d = v1.float_value (); | |
75 | |
76 if (d == 0.0) | |
77 gripe_divide_by_zero (); | |
78 | |
79 return octave_value (v2.float_value () / d); | |
80 } | |
81 | |
82 DEFBINOP_OP (lt, float_scalar, float_scalar, <) | |
83 DEFBINOP_OP (le, float_scalar, float_scalar, <=) | |
84 DEFBINOP_OP (eq, float_scalar, float_scalar, ==) | |
85 DEFBINOP_OP (ge, float_scalar, float_scalar, >=) | |
86 DEFBINOP_OP (gt, float_scalar, float_scalar, >) | |
87 DEFBINOP_OP (ne, float_scalar, float_scalar, !=) | |
88 | |
89 DEFBINOP_OP (el_mul, float_scalar, float_scalar, *) | |
90 | |
91 DEFBINOP (el_div, float_scalar, float_scalar) | |
92 { | |
93 CAST_BINOP_ARGS (const octave_float_scalar&, const octave_float_scalar&); | |
94 | |
95 float d = v2.float_value (); | |
96 | |
97 if (d == 0.0) | |
98 gripe_divide_by_zero (); | |
99 | |
100 return octave_value (v1.float_value () / d); | |
101 } | |
102 | |
103 DEFBINOP_FN (el_pow, float_scalar, float_scalar, xpow) | |
104 | |
105 DEFBINOP (el_ldiv, float_scalar, float_scalar) | |
106 { | |
107 CAST_BINOP_ARGS (const octave_float_scalar&, const octave_float_scalar&); | |
108 | |
109 float d = v1.float_value (); | |
110 | |
111 if (d == 0.0) | |
112 gripe_divide_by_zero (); | |
113 | |
114 return octave_value (v2.float_value () / d); | |
115 } | |
116 | |
117 DEFBINOP_OP (el_and, float_scalar, float_scalar, &&) | |
118 DEFBINOP_OP (el_or, float_scalar, float_scalar, ||) | |
119 | |
120 DEFNDCATOP_FN (fs_fs, float_scalar, float_scalar, float_array, float_array, concat) | |
121 | |
122 CONVDECL (float_to_scalar) | |
123 { | |
124 CAST_CONV_ARG (const octave_float_scalar&); | |
125 | |
126 return new octave_matrix (Matrix (1, 1, static_cast<double>(v.float_value ()))); | |
127 } | |
128 | |
129 void | |
130 install_fs_fs_ops (void) | |
131 { | |
132 INSTALL_UNOP (op_not, octave_float_scalar, not); | |
133 INSTALL_UNOP (op_uplus, octave_float_scalar, uplus); | |
134 INSTALL_UNOP (op_uminus, octave_float_scalar, uminus); | |
135 INSTALL_UNOP (op_transpose, octave_float_scalar, transpose); | |
136 INSTALL_UNOP (op_hermitian, octave_float_scalar, hermitian); | |
137 | |
138 INSTALL_NCUNOP (op_incr, octave_float_scalar, incr); | |
139 INSTALL_NCUNOP (op_decr, octave_float_scalar, decr); | |
140 | |
141 INSTALL_BINOP (op_add, octave_float_scalar, octave_float_scalar, add); | |
142 INSTALL_BINOP (op_sub, octave_float_scalar, octave_float_scalar, sub); | |
143 INSTALL_BINOP (op_mul, octave_float_scalar, octave_float_scalar, mul); | |
144 INSTALL_BINOP (op_div, octave_float_scalar, octave_float_scalar, div); | |
145 INSTALL_BINOP (op_pow, octave_float_scalar, octave_float_scalar, pow); | |
146 INSTALL_BINOP (op_ldiv, octave_float_scalar, octave_float_scalar, ldiv); | |
147 INSTALL_BINOP (op_lt, octave_float_scalar, octave_float_scalar, lt); | |
148 INSTALL_BINOP (op_le, octave_float_scalar, octave_float_scalar, le); | |
149 INSTALL_BINOP (op_eq, octave_float_scalar, octave_float_scalar, eq); | |
150 INSTALL_BINOP (op_ge, octave_float_scalar, octave_float_scalar, ge); | |
151 INSTALL_BINOP (op_gt, octave_float_scalar, octave_float_scalar, gt); | |
152 INSTALL_BINOP (op_ne, octave_float_scalar, octave_float_scalar, ne); | |
153 INSTALL_BINOP (op_el_mul, octave_float_scalar, octave_float_scalar, el_mul); | |
154 INSTALL_BINOP (op_el_div, octave_float_scalar, octave_float_scalar, el_div); | |
155 INSTALL_BINOP (op_el_pow, octave_float_scalar, octave_float_scalar, el_pow); | |
156 INSTALL_BINOP (op_el_ldiv, octave_float_scalar, octave_float_scalar, el_ldiv); | |
157 INSTALL_BINOP (op_el_and, octave_float_scalar, octave_float_scalar, el_and); | |
158 INSTALL_BINOP (op_el_or, octave_float_scalar, octave_float_scalar, el_or); | |
159 | |
160 INSTALL_CATOP (octave_float_scalar, octave_float_scalar, fs_fs); | |
161 | |
162 INSTALL_ASSIGNCONV (octave_float_scalar, octave_float_scalar, octave_float_matrix); | |
163 INSTALL_ASSIGNCONV (octave_scalar, octave_float_scalar, octave_matrix); | |
164 | |
165 INSTALL_CONVOP (octave_float_scalar, octave_matrix, float_to_scalar); | |
166 } | |
167 | |
168 /* | |
169 ;;; Local Variables: *** | |
170 ;;; mode: C++ *** | |
171 ;;; End: *** | |
172 */ |