annotate main/fixed/src/fixed.cc @ 3272:17e102866239 octave-forge

FSF address update
author adb014
date Fri, 23 Mar 2007 20:59:58 +0000
parents 73fa4496fb07
children 2de537641f94
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1 /*
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
2
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
3 Copyright (C) 2003 Motorola Inc
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
4 Copyright (C) 2003 David Bateman
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
5
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
6 This program is free software; you can redistribute it and/or modify it
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
9 later version.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
10
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
11 This program is distributed in the hope that it will be useful, but WITHOUT
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
14 for more details.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
15
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
17 along with this program; see the file COPYING. If not, write to the Free
3272
17e102866239 FSF address update
adb014
parents: 3268
diff changeset
18 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
19
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
20 In addition to the terms of the GPL, you are permitted to link
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
21 this program with any Open Source program, as defined by the
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
22 Open Source Initiative (www.opensource.org)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
23
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
24 */
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
25
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
26 #include "ov-fixed.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
27 #include "ov-fixed-mat.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
28 #include "ov-fixed-complex.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
29 #include "ov-fixed-cx-mat.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
30 #include "fixed-var.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
31
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
32 #include <octave/variables.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
33 #include <octave/utils.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
34 #include <octave/pager.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
35 #include <octave/defun-dld.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
36 #include <octave/gripes.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
37
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
38 extern void install_fs_fs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
39 extern void install_fs_fm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
40 extern void install_fm_fs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
41 extern void install_fm_fm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
42
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
43 extern void install_fs_fcs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
44 extern void install_fs_fcm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
45 extern void install_fm_fcs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
46 extern void install_fm_fcm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
47
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
48 extern void install_fcs_fs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
49 extern void install_fcs_fm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
50 extern void install_fcm_fs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
51 extern void install_fcm_fm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
52
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
53 extern void install_fcs_fcs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
54 extern void install_fcs_fcm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
55 extern void install_fcm_fcs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
56 extern void install_fcm_fcm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
57
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
58 static bool fixed_type_loaded = false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
59
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
60 void load_fixed_type (void)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
61 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
62 octave_fixed::register_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
63 octave_fixed_matrix::register_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
64 octave_fixed_complex::register_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
65 octave_fixed_complex_matrix::register_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
66
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
67 install_fs_fs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
68 install_fs_fm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
69 install_fm_fs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
70 install_fm_fm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
71
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
72 install_fs_fcs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
73 install_fs_fcm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
74 install_fm_fcs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
75 install_fm_fcm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
76
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
77 install_fcs_fs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
78 install_fcs_fm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
79 install_fcm_fs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
80 install_fcm_fm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
81
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
82 install_fcs_fcs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
83 install_fcs_fcm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
84 install_fcm_fcs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
85 install_fcm_fcm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
86
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
87 fixed_type_loaded = true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
88
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
89 // Lock constructor function in place, otherwise
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
90 // "a=fixed(3,1); clear functions; a" generates a seg-fault!!
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
91 // The below is the function "mlock", but in a way useable
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
92 // for older versions of octave as well.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
93 fbi_sym_tab->lookup("fixed")->mark_as_static ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
94 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
95
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
96 DEFUN_DLD (display_fixed_operations, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
97 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
98 "@deftypefn {Loadable Function} {} display_fixed_operations ( )\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
99 "Displays out a summary of the number of fixed point operations of each\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
100 "type that have been used. This can be used to give a estimate of the\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
101 "complexity of an algorithm.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
102 "@end deftypefn\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
103 "@seealso{fixed_point_count_operations, reset_fixed_operations}")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
104 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
105 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
106 if ((args.length() != 0) || !fixed_type_loaded)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
107 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
108 else if (Fixed::FP_CountOperations)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
109 octave_stdout << Fixed::FP_Operations;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
110 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
111 error("display_fixed_operations: variable fixed_point_count_operations is zero");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
112
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
113 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
114 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
115
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
116 DEFUN_DLD (reset_fixed_operations, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
117 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
118 "@deftypefn {Loadable Function} {} reset_fixed_operations ( )\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
119 "Reset the count of fixed point operations to zero.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
120 "@end deftypefn\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
121 "@seealso{fixed_point_count_operations, display_fixed_operations}")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
122 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
123 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
124 if ((args.length() != 0) || !fixed_type_loaded)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
125 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
126 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
127 Fixed::FP_Operations.reset();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
128
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
129 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
130 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
131
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
132 DEFUN_DLD (isfixed, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
133 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
134 "@deftypefn {Loadable Function} {} isfixed (@var{expr})\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
135 "Return 1 if the value of the expression @var{expr} is a fixed point value.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
136 "@end deftypefn")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
137 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
138 if (args.length() != 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
139 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
140 else if (!fixed_type_loaded)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
141 // Can't be of fixed type if the type isn't load :-/
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
142 return octave_value(false);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
143 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
144 return (octave_value((args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
145 octave_fixed::static_type_id ()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
146 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
147 octave_fixed_matrix::static_type_id ()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
148 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
149 octave_fixed_complex::static_type_id ()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
150 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
151 octave_fixed_complex_matrix::static_type_id ())));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
152 return octave_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
153 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
154
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
155 DEFUN_DLD (fixed, args, nargout,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
156 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
157 "@deftypefn {Loadable Function} {@var{y} =} fixed (@var{f})\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
158 "@deftypefnx {Loadable Function} {@var{y} =} fixed (@var{is},@var{ds})\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
159 "@deftypefnx {Loadable Function} {@var{y} =} fixed (@var{is},@var{ds},@var{f})\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
160 "Used the create a fixed point variable. Called with a single argument, if\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
161 "@var{f} is itself a fixed point value, then @dfn{fixed} is equivalent to\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
162 "@code{@var{y} = @var{f}}. Otherwise the integer part of @var{f} is used\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
163 "to create a fixed point variable with the minimum number of bits needed\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
164 "to represent it. @var{f} can be either real of complex.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
165 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
166 "Called with two or more arguments @var{is} represents the number of bits\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
167 "used to represent the integer part of the fixed point numbers, and @var{ds}\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
168 "the number used to represent the decimal part. These variables must be\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
169 "either positive integer scalars or matrices. If they are matrices they\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
170 "must be of the same dimension, and each fixed point number in the created\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
171 "matrix will have the representation given by the corresponding values of\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
172 "@var{is} and @var{ds}.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
173 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
174 "When creating complex fixed point values, the fixed point representation\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
175 "can be different for the real and imaginary parts. In this case @var{is}\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
176 "and @var{ds} are complex integers."
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
177 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
178 "Additionally the maximum value of the sum of @var{is} and @var{ds} is\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
179 "limited by the representation of long integers to either 30 or 62.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
180 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
181 "Called with only two arguments, the fixed point variable that is created\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
182 "will contain only zeros. A third argument can be used to give the values\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
183 "of the fixed variables elements. This third argument @var{f} can be either\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
184 "a fixed point variable itself, which results in a new fixed point variable\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
185 "being created with a different representation, or a real or complex matrix.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
186 "@end deftypefn\n")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
187 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
188 int nargin = args.length();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
189 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
190
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
191 if ( nargin == 0 ) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
192 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
193 } else if (nargin == 1 ) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
194 if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
195 (args(0).type_id () == octave_fixed_matrix::static_type_id ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
196 FixedMatrix f = ((const octave_fixed_matrix&) args(0).get_rep()).
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
197 fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
198 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
199 } else if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
200 (args(0).type_id () == octave_fixed::static_type_id ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
201 FixedPoint f = ((const octave_fixed&) args(0).get_rep()).fixed_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
202 retval = new octave_fixed (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
203 } else if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
204 (args(0).type_id () == octave_fixed_complex::static_type_id ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
205 FixedPointComplex f = ((const octave_fixed_complex&)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
206 args(0).get_rep()).fixed_complex_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
207 retval = new octave_fixed_complex (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
208 } else if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
209 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
210 octave_fixed_complex_matrix::static_type_id ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
211 FixedComplexMatrix f = ((const octave_fixed_complex_matrix&)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
212 args(0).get_rep()).fixed_complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
213 retval = new octave_fixed_complex_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
214 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
215 if (args(0).is_complex_type()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
216 ComplexMatrix a = args(0).complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
217 MArray2<int> b(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
218 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
219 for (int i = 0; i < a.rows(); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
220 b(i,j) = (int)real(a(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
221 FixedMatrix fr(b);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
222 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
223 for (int i = 0; i < a.rows(); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
224 b(i,j) = (int)imag(a(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
225 FixedMatrix fi(b);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
226 retval = new octave_fixed_complex_matrix (fr, fi);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
227 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
228 Matrix a = args(0).matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
229 MArray2<int> b(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
230 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
231 for (int i = 0; i < a.rows(); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
232 b(i,j) = (int)a(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
233 FixedMatrix f(b);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
234 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
235 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
236 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
237 } else if ((nargin ==2) || (nargin == 3)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
238 if (args(0).is_complex_type() || args(1).is_complex_type() ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
239 ((nargin > 2) && args(2).is_complex_type())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
240
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
241 MArray2<int> mir, mii, mdr, mdi;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
242 ComplexMatrix a, b;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
243 if (args(0).is_complex_type())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
244 a = args(0).complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
245 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
246 a = ComplexMatrix(args(0).matrix_value());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
247 a = a + Complex(0.,1.)*a;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
248 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
249 if (args(1).is_complex_type())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
250 b = args(1).complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
251 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
252 b = ComplexMatrix(args(1).matrix_value());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
253 b = b + Complex(0.,1.)*b;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
254 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
255
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
256 mir.resize(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
257 mii.resize(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
258 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
259 for (int i = 0; i < a.rows(); i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
260 mir(i,j) = (int) real(a(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
261 mii(i,j) = (int) imag(a(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
262 if ((std::abs(real(a(i,j))-(double)mir(i,j)) != 0.) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
263 (std::abs(imag(a(i,j))-(double)mii(i,j)) != 0.) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
264 (mir(i,j) < 0) || (mii(i,j) < 0)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
265 error("fixed: invalid fixed point representation");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
266 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
267 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
268 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
269
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
270 mdr.resize(b.rows(),b.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
271 mdi.resize(b.rows(),b.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
272 for (int j = 0; j < b.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
273 for (int i = 0; i < b.rows(); i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
274 mdr(i,j) = (int) real(b(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
275 mdi(i,j) = (int) imag(b(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
276 if ((std::abs(real(b(i,j))-(double)mdr(i,j)) != 0.) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
277 (std::abs(imag(b(i,j))-(double)mdi(i,j)) != 0.) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
278 (mir(i,j) < 0) || (mdi(i,j) < 0)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
279 error("fixed: invalid fixed point representation");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
280 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
281 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
282 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
283
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
284 if ((mir.rows() == 1) && (mir.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
285 mir.resize(mdr.rows(),mdr.cols(),mir(0,0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
286 mii.resize(mdr.rows(),mdr.cols(),mii(0,0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
287 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
288 if ((mdr.rows() == 1) && (mdr.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
289 mdr.resize(mir.rows(),mir.cols(),mdr(0,0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
290 mdi.resize(mir.rows(),mir.cols(),mdi(0,0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
291 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
292
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
293 if ((mir.rows() != mdr.rows()) || (mir.cols() != mdr.cols())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
294 error("fixed: dimension mismatch in args");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
295 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
296 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
297
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
298 if (nargin == 2 ) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
299 if (!fixed_type_loaded) load_fixed_type();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
300 if ((mir.rows() == 1) && (mir.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
301 FixedPointComplex f( FixedPoint((int)mir(0,0), (int)mdr(0,0)),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
302 FixedPoint((int)mii(0,0), (int)mdi(0,0)));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
303 retval = new octave_fixed_complex (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
304 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
305 FixedComplexMatrix f (FixedMatrix (mir, mdr),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
306 FixedMatrix (mii, mdi));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
307 retval = new octave_fixed_complex_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
308 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
309 } else if (nargin == 3) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
310 ComplexMatrix c = args(2).complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
311 if ((mir.rows() == 1) && (mir.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
312 if (!fixed_type_loaded) load_fixed_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
313 FixedComplexMatrix f(FixedMatrix((int)mir(0,0), (int)mdr(0,0),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
314 real(c)),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
315 FixedMatrix((int)mii(0,0), (int)mdi(0,0),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
316 imag(c)));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
317 retval = new octave_fixed_complex_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
318 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
319 if ((mir.rows() != c.rows()) || (mir.cols() != c.cols()))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
320 error("fixed: dimension mismatch in args");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
321 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
322 if (!fixed_type_loaded) load_fixed_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
323 FixedComplexMatrix f(FixedMatrix(mir, mdr, real(c)),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
324 FixedMatrix(mii, mdi, imag(c)));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
325 retval = new octave_fixed_complex_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
326 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
327 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
328 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
329 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
330 MArray2<int> mis, mds;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
331 Matrix a = args(0).matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
332 Matrix b = args(1).matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
333
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
334 mis.resize(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
335 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
336 for (int i = 0; i < a.rows(); i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
337 mis(i,j) = (int)a(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
338 if ((std::abs(a(i,j)-(double)mis(i,j)) != 0.) || (mis(i,j) < 0)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
339 error("fixed: invalid fixed point representation");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
340 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
341 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
342 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
343 mds.resize(b.rows(),b.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
344 for (int j=0; j < b.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
345 for (int i=0; i < b.rows(); i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
346 mds(i,j) = (int)b(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
347 if ((std::abs(b(i,j)-(double)mds(i,j)) != 0.) || (mds(i,j) < 0)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
348 error("fixed: invalid fixed point representation");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
349 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
350 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
351 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
352
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
353 if ((mis.rows() == 1) && (mis.cols() == 1))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
354 mis.resize(mds.rows(),mds.cols(),mis(0,0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
355 if ((mds.rows() == 1) && (mds.cols() == 1))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
356 mds.resize(mis.rows(),mis.cols(),mds(0,0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
357
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
358 if ((mis.rows() != mds.rows()) || (mis.cols() != mds.cols())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
359 error("fixed: dimension mismatch in args");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
360 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
361 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
362
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
363 if (nargin == 2 ) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
364 if (!fixed_type_loaded) load_fixed_type();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
365 if ((mis.rows() == 1) && (mis.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
366 FixedPoint f(mis(0,0), mds(0,0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
367 retval = new octave_fixed (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
368 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
369 FixedMatrix f(mis, mds);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
370 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
371 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
372 } else if (nargin == 3) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
373 Matrix a = args(2).matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
374 if ((mis.rows() == 1) && (mis.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
375 if (!fixed_type_loaded) load_fixed_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
376 FixedMatrix f (mis(0,0), mds(0,0), a);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
377 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
378 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
379 if ((mis.rows() != a.rows()) || (mis.cols() != a.cols()))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
380 error("fixed: dimension mismatch in args");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
381 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
382 if (!fixed_type_loaded) load_fixed_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
383 FixedMatrix f (mis, mds, a);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
384 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
385 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
386 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
387 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
388 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
389 } else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
390 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
391
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
392
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
393 if (error_state) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
394 error("fixed: failed to create fixed point number");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
395 return octave_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
396 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
397 retval.maybe_mutate();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
398 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
399 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
400 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
401
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
402 // This macro must start with DEFUN_DLD so that the automatic collection
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
403 // of the function helps can take place!! The second DEFUN_DLD must NOT
2870
96854eb1408c modify macro to aid indexing
adb014
parents: 2605
diff changeset
404 // appear on a new-line, otherwise the indexing script will be confused!!
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
405 #define DEFUN_DLD_FIXED_SNGL_ARG(NAME, HELP, FUNC, \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
406 REAL_CAN_RET_CMPLX_UPPER,UPPER, REAL_CAN_RET_CMPLX_LOWER, \
2605
4ee580968fce Some INDEX fixes. Many more needed
adb014
parents: 2394
diff changeset
407 LOWER) DEFUN_DLD (NAME, args, nargout, HELP) \
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
408 { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
409 int nargin = args.length(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
410 octave_value retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
411 if ( nargin != 1 ) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
412 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
413 } else { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
414 if (fixed_type_loaded) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
415 if (args(0).type_id () == octave_fixed::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
416 FixedPoint f = ((const octave_fixed&) args(0).get_rep()) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
417 .fixed_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
418 if ((REAL_CAN_RET_CMPLX_UPPER && (f.fixedpoint() > UPPER)) || \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
419 (REAL_CAN_RET_CMPLX_LOWER && (f.fixedpoint() < LOWER))) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
420 retval = new octave_fixed_complex \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
421 (FUNC (FixedPointComplex(f,FixedPoint(f.getintsize(), \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
422 f.getdecsize())))); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
423 else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
424 retval = new octave_fixed (FUNC (f)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
425 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
426 octave_fixed_matrix::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
427 FixedMatrix f = ((const octave_fixed_matrix&) args(0).get_rep()) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
428 .fixed_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
429 if ((REAL_CAN_RET_CMPLX_UPPER && (f.row_max().max().fixedpoint() \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
430 > UPPER)) || \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
431 (REAL_CAN_RET_CMPLX_LOWER && (f.row_min().min().fixedpoint() \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
432 < LOWER))) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
433 retval = new octave_fixed_complex_matrix \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
434 (FUNC (FixedComplexMatrix(f))); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
435 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
436 retval = new octave_fixed_matrix (FUNC (f)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
437 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
438 octave_fixed_complex::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
439 FixedPointComplex f = ((const octave_fixed_complex&) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
440 args(0).get_rep()).fixed_complex_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
441 retval = new octave_fixed_complex (FUNC (f)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
442 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
443 octave_fixed_complex_matrix::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
444 FixedComplexMatrix f = ((const octave_fixed_complex_matrix&) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
445 args(0).get_rep()).fixed_complex_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
446 retval = new octave_fixed_complex_matrix (FUNC (f)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
447 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
448 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
449 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
450 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
451 } \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
452 retval.maybe_mutate(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
453 return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
454 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
455
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
456 // PKG_ADD: dispatch ("real", "freal", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
457 // PKG_ADD: dispatch ("real", "freal", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
458 // PKG_ADD: dispatch ("real", "freal", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
459 // PKG_ADD: dispatch ("real", "freal", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
460 DEFUN_DLD_FIXED_SNGL_ARG (freal, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
461 @deftypefn {Loadable Function} {@var{y} =} freal (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
462 Returns the real part of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
463 @end deftypefn", ::real, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
464
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
465 // PKG_ADD: dispatch ("imag", "fimag", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
466 // PKG_ADD: dispatch ("imag", "fimag", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
467 // PKG_ADD: dispatch ("imag", "fimag", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
468 // PKG_ADD: dispatch ("imag", "fimag", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
469 DEFUN_DLD_FIXED_SNGL_ARG (fimag, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
470 @deftypefn {Loadable Function} {@var{y} =} fimag (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
471 Returns the imaginary part of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
472 @end deftypefn", ::imag, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
473
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
474 // PKG_ADD: dispatch ("conj", "fconj", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
475 // PKG_ADD: dispatch ("conj", "fconj", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
476 // PKG_ADD: dispatch ("conj", "fconj", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
477 // PKG_ADD: dispatch ("conj", "fconj", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
478 DEFUN_DLD_FIXED_SNGL_ARG (fconj, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
479 @deftypefn {Loadable Function} {@var{y} =} fconj (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
480 Returns the conjuate of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
481 @end deftypefn", ::conj, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
482
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
483 // PKG_ADD: dispatch ("abs", "fabs", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
484 // PKG_ADD: dispatch ("abs", "fabs", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
485 // PKG_ADD: dispatch ("abs", "fabs", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
486 // PKG_ADD: dispatch ("abs", "fabs", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
487 DEFUN_DLD_FIXED_SNGL_ARG (fabs, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
488 @deftypefn {Loadable Function} {@var{y} =} fabs (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
489 Compute the magnitude of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
490 @end deftypefn", ::abs, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
491
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
492 // PKG_ADD: dispatch ("arg", "farg", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
493 // PKG_ADD: dispatch ("arg", "farg", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
494 // PKG_ADD: dispatch ("arg", "farg", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
495 // PKG_ADD: dispatch ("arg", "farg", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
496 DEFUN_DLD_FIXED_SNGL_ARG (farg, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
497 @deftypefn {Loadable Function} {@var{y} =} farg (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
498 Compute the argument of @var{x}, defined as\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
499 @iftex\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
500 @tex\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
501 $\\theta = atan2( y , x)$\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
502 @end tex\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
503 @end iftex\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
504 @ifinfo\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
505 @var{theta} = @code{atan2 (@var{y}, @var{x})}\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
506 @end ifinfo\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
507 in radians. For example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
508 \n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
509 @example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
510 @group\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
511 farg (fixed (3,5,3+4i))\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
512 @result{} 0.90625\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
513 @end group\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
514 @end example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
515 @end deftypefn", ::arg, 1, FixedPoint(1,0,1,0), 1, FixedPoint())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
516
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
517 // PKG_ADD: dispatch ("angle", "fangle", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
518 // PKG_ADD: dispatch ("angle", "fangle", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
519 // PKG_ADD: dispatch ("angle", "fangle", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
520 // PKG_ADD: dispatch ("angle", "fangle", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
521 DEFUN_DLD_FIXED_SNGL_ARG (fangle, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
522 @deftypefn {Loadable Function} {@var{y} =} fangle (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
523 See @dfn{farg}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
524 @end deftypefn", ::arg, 1, FixedPoint(1,0,1,0), 1, FixedPoint())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
525
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
526 // PKG_ADD: dispatch ("cos", "fcos", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
527 // PKG_ADD: dispatch ("cos", "fcos", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
528 // PKG_ADD: dispatch ("cos", "fcos", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
529 // PKG_ADD: dispatch ("cos", "fcos", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
530 DEFUN_DLD_FIXED_SNGL_ARG (fcos, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
531 @deftypefn {Loadable Function} {@var{y} =} fcos (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
532 Compute the cosine of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
533 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
534 @seealso{fcosh, fsin, fsinh, ftan, ftanh}", ::cos, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
535
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
536 // PKG_ADD: dispatch ("cosh", "fcosh", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
537 // PKG_ADD: dispatch ("cosh", "fcosh", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
538 // PKG_ADD: dispatch ("cosh", "fcosh", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
539 // PKG_ADD: dispatch ("cosh", "fcosh", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
540 DEFUN_DLD_FIXED_SNGL_ARG (fcosh, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
541 @deftypefn {Loadable Function} {@var{y} =} fcosh (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
542 Compute the hyperbolic cosine of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
543 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
544 @seealso{fcos, fsin, fsinh, ftan, ftanh}", ::cosh, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
545
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
546 // PKG_ADD: dispatch ("sin", "fsin", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
547 // PKG_ADD: dispatch ("sin", "fsin", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
548 // PKG_ADD: dispatch ("sin", "fsin", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
549 // PKG_ADD: dispatch ("sin", "fsin", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
550 DEFUN_DLD_FIXED_SNGL_ARG (fsin, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
551 @deftypefn {Loadable Function} {@var{y} =} fsin (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
552 Compute the sine of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
553 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
554 @seealso{fcos, fcosh, fsinh, ftan, ftanh}", ::sin, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
555
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
556 // PKG_ADD: dispatch ("sinh", "fsinh", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
557 // PKG_ADD: dispatch ("sinh", "fsinh", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
558 // PKG_ADD: dispatch ("sinh", "fsinh", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
559 // PKG_ADD: dispatch ("sinh", "fsinh", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
560 DEFUN_DLD_FIXED_SNGL_ARG (fsinh, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
561 @deftypefn {Loadable Function} {@var{y} =} fsinh (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
562 Compute the hyperbolic sine of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
563 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
564 @seealso{fcos, fcosh, fsin, ftan, ftanh}", ::sinh, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
565
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
566 // PKG_ADD: dispatch ("tan", "ftan", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
567 // PKG_ADD: dispatch ("tan", "ftan", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
568 // PKG_ADD: dispatch ("tan", "ftan", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
569 // PKG_ADD: dispatch ("tan", "ftan", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
570 DEFUN_DLD_FIXED_SNGL_ARG (ftan, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
571 @deftypefn {Loadable Function} {@var{y} =} ftan (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
572 Compute the tan of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
573 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
574 @seealso{fcos, fcosh, fsinh, ftan, ftanh}", ::tan, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
575
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
576 // PKG_ADD: dispatch ("tanh", "ftanh", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
577 // PKG_ADD: dispatch ("tanh", "ftanh", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
578 // PKG_ADD: dispatch ("tanh", "ftanh", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
579 // PKG_ADD: dispatch ("tanh", "ftanh", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
580 DEFUN_DLD_FIXED_SNGL_ARG (ftanh, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
581 @deftypefn {Loadable Function} {@var{y} =} ftanh (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
582 Compute the hyperbolic tan of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
583 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
584 @seealso{fcos, fcosh, fsin, fsinh, ftan}", ::tanh, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
585
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
586 // PKG_ADD: dispatch ("sqrt", "fsqrt", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
587 // PKG_ADD: dispatch ("sqrt", "fsqrt", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
588 // PKG_ADD: dispatch ("sqrt", "fsqrt", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
589 // PKG_ADD: dispatch ("sqrt", "fsqrt", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
590 DEFUN_DLD_FIXED_SNGL_ARG (fsqrt, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
591 @deftypefn {Loadable Function} {@var{y} =} fsqrt (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
592 Compute the square-root of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
593 @end deftypefn", ::sqrt, 0, 0, 1, FixedPoint());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
594
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
595 // PKG_ADD: dispatch ("exp", "fexp", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
596 // PKG_ADD: dispatch ("exp", "fexp", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
597 // PKG_ADD: dispatch ("exp", "fexp", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
598 // PKG_ADD: dispatch ("exp", "fexp", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
599 DEFUN_DLD_FIXED_SNGL_ARG (fexp, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
600 @deftypefn {Loadable Function} {@var{y} =} fexp (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
601 Compute the exponential of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
602 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
603 @seealso{log, log10, pow}", ::exp, 0, 0, 0, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
604
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
605 // PKG_ADD: dispatch ("log", "flog", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
606 // PKG_ADD: dispatch ("log", "flog", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
607 // PKG_ADD: dispatch ("log", "flog", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
608 // PKG_ADD: dispatch ("log", "flog", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
609 DEFUN_DLD_FIXED_SNGL_ARG (flog, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
610 @deftypefn {Loadable Function} {@var{y} =} flog (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
611 Compute the natural logarithm of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
612 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
613 @seealso{fexp, flog10, fpow}", ::log, 0, 0, 1, FixedPoint());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
614
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
615 // PKG_ADD: dispatch ("log10", "flog10", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
616 // PKG_ADD: dispatch ("log10", "flog10", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
617 // PKG_ADD: dispatch ("log10", "flog10", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
618 // PKG_ADD: dispatch ("log10", "flog10", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
619 DEFUN_DLD_FIXED_SNGL_ARG (flog10, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
620 @deftypefn {Loadable Function} {@var{y} =} flog10 (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
621 Compute the base-10 logarithm of the fixed point value @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
622 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
623 @seealso{fexp, flog, fpow}", ::log10, 0, 0, 1, FixedPoint());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
624
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
625 // PKG_ADD: dispatch ("round", "fround", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
626 // PKG_ADD: dispatch ("round", "fround", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
627 // PKG_ADD: dispatch ("round", "fround", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
628 // PKG_ADD: dispatch ("round", "fround", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
629 DEFUN_DLD_FIXED_SNGL_ARG (fround, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
630 @deftypefn {Loadable Function} {@var{y} =} fround (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
631 Return the rounded value to the nearest integer of @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
632 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
633 @seealso{ffloor, fceil}", ::round, 0, 0, 0, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
634
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
635 // PKG_ADD: dispatch ("floor", "ffloor", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
636 // PKG_ADD: dispatch ("floor", "ffloor", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
637 // PKG_ADD: dispatch ("floor", "ffloor", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
638 // PKG_ADD: dispatch ("floor", "ffloor", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
639 DEFUN_DLD_FIXED_SNGL_ARG (ffloor, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
640 @deftypefn {Loadable Function} {@var{y} =} ffloor (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
641 Return the largest integer not greater than @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
642 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
643 @seealso{fround, fceil}", ::floor, 0, 0, 0, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
644
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
645 // PKG_ADD: dispatch ("ceil", "fceil", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
646 // PKG_ADD: dispatch ("ceil", "fceil", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
647 // PKG_ADD: dispatch ("ceil", "fceil", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
648 // PKG_ADD: dispatch ("ceil", "fceil", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
649 DEFUN_DLD_FIXED_SNGL_ARG (fceil, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
650 @deftypefn {Loadable Function} {@var{y} =} fceil (@var{x})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
651 Return the smallest integer not less than @var{x}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
652 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
653 @seealso{fround, ffloor}", ::ceil, 0, 0, 0, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
654
2870
96854eb1408c modify macro to aid indexing
adb014
parents: 2605
diff changeset
655 // This macro must start with DEFUN_DLD so that the automatic collection
96854eb1408c modify macro to aid indexing
adb014
parents: 2605
diff changeset
656 // of the function helps can take place!! The second DEFUN_DLD must NOT
96854eb1408c modify macro to aid indexing
adb014
parents: 2605
diff changeset
657 // appear on a new-line, otherwise the indexing script will be confused!!
96854eb1408c modify macro to aid indexing
adb014
parents: 2605
diff changeset
658 #define DEFUN_DLD_FIXED_DIM_ARG(NAME, HELP, FUNC) DEFUN_DLD (NAME, args, nargout, HELP) \
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
659 { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
660 int nargin = args.length(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
661 octave_value retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
662 if ((nargin != 1 ) && (nargin != 2)) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
663 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
664 else { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
665 int dim = (nargin == 1 ? -1 : args(1).int_value(true) - 1); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
666 if (error_state) return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
667 if (dim < -1 || dim > 1) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
668 error (#NAME ": invalid dimension argument = %d", dim + 1); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
669 return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
670 } \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
671 if (fixed_type_loaded) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
672 if (args(0).type_id () == octave_fixed::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
673 FixedMatrix f = ((const octave_fixed&) args(0).get_rep()) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
674 .fixed_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
675 retval = new octave_fixed( f .FUNC (dim) (0,0)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
676 } else if (args(0).type_id () == octave_fixed_complex:: \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
677 static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
678 FixedComplexMatrix f = ((const octave_fixed_complex&) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
679 args(0).get_rep()).fixed_complex_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
680 retval = new octave_fixed_complex(f .FUNC (dim) (0,0)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
681 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
682 octave_fixed_matrix::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
683 FixedMatrix f = ((const octave_fixed_matrix&) args(0).get_rep()) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
684 .fixed_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
685 retval = new octave_fixed_matrix(f .FUNC (dim)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
686 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
687 octave_fixed_complex_matrix::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
688 FixedComplexMatrix f = ((const octave_fixed_complex_matrix&) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
689 args(0).get_rep()).fixed_complex_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
690 retval = new octave_fixed_complex_matrix(f .FUNC (dim)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
691 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
692 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
693 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
694 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
695 } \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
696 retval.maybe_mutate(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
697 return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
698 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
699
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
700 // PKG_ADD: dispatch ("prod", "fprod", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
701 // PKG_ADD: dispatch ("prod", "fprod", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
702 // PKG_ADD: dispatch ("prod", "fprod", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
703 // PKG_ADD: dispatch ("prod", "fprod", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
704 DEFUN_DLD_FIXED_DIM_ARG (fprod, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
705 @deftypefn {Loadable Function} {@var{y} =} fprod (@var{x},@var{dim})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
706 Product of elements along dimension @var{dim}. If @var{dim} is omitted,\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
707 it defaults to 1 (column-wise products).\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
708 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
709 @seealso{fsum, fsumsq}", prod)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
710
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
711 // PKG_ADD: dispatch ("cumprod", "fcumprod", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
712 // PKG_ADD: dispatch ("cumprod", "fcumprod", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
713 // PKG_ADD: dispatch ("cumprod", "fcumprod", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
714 // PKG_ADD: dispatch ("cumprod", "fcumprod", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
715 DEFUN_DLD_FIXED_DIM_ARG (fcumprod, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
716 @deftypefn {Loadable Function} {@var{y} =} fcumprod (@var{x},@var{dim})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
717 Cumulative product of elements along dimension @var{dim}. If @var{dim}\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
718 is omitted, it defaults to 1 (column-wise cumulative products).\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
719 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
720 @seealso{fcumsum}", cumprod)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
721
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
722 // PKG_ADD: dispatch ("sum", "fsum", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
723 // PKG_ADD: dispatch ("sum", "fsum", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
724 // PKG_ADD: dispatch ("sum", "fsum", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
725 // PKG_ADD: dispatch ("sum", "fsum", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
726 DEFUN_DLD_FIXED_DIM_ARG (fsum, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
727 @deftypefn {Loadable Function} {@var{y} =} fsum (@var{x},@var{dim})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
728 Sum of elements along dimension @var{dim}. If @var{dim} is omitted, it\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
729 defaults to 1 (column-wise sum).\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
730 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
731 @seealso{fprod, fsumsq}", sum)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
732
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
733 // PKG_ADD: dispatch ("cumsum", "fcumsum", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
734 // PKG_ADD: dispatch ("cumsum", "fcumsum", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
735 // PKG_ADD: dispatch ("cumsum", "fcumsum", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
736 // PKG_ADD: dispatch ("cumsum", "fcumsum", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
737 DEFUN_DLD_FIXED_DIM_ARG (fcumsum, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
738 @deftypefn {Loadable Function} {@var{y} =} fcumsum (@var{x},@var{dim})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
739 Cumulative sum of elements along dimension @var{dim}. If @var{dim}\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
740 is omitted, it defaults to 1 (column-wise cumulative sums).\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
741 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
742 @seealso{fcumprod}", cumsum)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
743
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
744 // PKG_ADD: dispatch ("sumsq", "fsumsq", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
745 // PKG_ADD: dispatch ("sumsq", "fsumsq", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
746 // PKG_ADD: dispatch ("sumsq", "fsumsq", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
747 // PKG_ADD: dispatch ("sumsq", "fsumsq", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
748 DEFUN_DLD_FIXED_DIM_ARG (fsumsq, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
749 @deftypefn {Loadable Function} {@var{y} =} fsumsq (@var{x},@var{dim})\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
750 Sum of squares of elements along dimension @var{dim}. If @var{dim}\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
751 is omitted, it defaults to 1 (column-wise sum of squares).\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
752 This function is equivalent to computing\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
753 @example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
754 fsum (x .* fconj (x), dim)\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
755 @end example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
756 but it uses less memory and avoids calling @code{fconj} if @var{x} is real.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
757 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
758 @seealso{fprod, fsum}", sumsq)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
759
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
760 // PKG_ADD: dispatch ("reshape", "freshape", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
761 // PKG_ADD: dispatch ("reshape", "freshape", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
762 // PKG_ADD: dispatch ("reshape", "freshape", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
763 // PKG_ADD: dispatch ("reshape", "freshape", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
764 DEFUN_DLD (freshape, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
765 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
766 "@deftypefn {Loadable Function} {} freshape (@var{a}, @var{m}, @var{n})\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
767 "Return a fixed matrix with @var{m} rows and @var{n} columns whose elements\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
768 "are taken from the fixed matrix @var{a}. To decide how to order the\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
769 "elements, Octave pretends that the elements of a matrix are stored in\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
770 "column-major order (like Fortran arrays are stored).\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
771 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
772 "For example,\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
773 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
774 "@example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
775 "freshape (fixed(3, 2, [1, 2, 3, 4]), 2, 2)\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
776 "ans =\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
777 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
778 " 1.00 3.00\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
779 " 2.00 4.00\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
780 "@end example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
781 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
782 "If the variable @code{do_fortran_indexing} is nonzero, the\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
783 "@code{freshape} function is equivalent to\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
784 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
785 "@example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
786 "@group\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
787 "retval = fixed(0,0,zeros (m, n));\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
788 "retval (:) = a;\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
789 "@end group\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
790 "@end example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
791 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
792 "@noindent\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
793 "but it is somewhat less cryptic to use @code{freshape} instead of the\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
794 "colon operator. Note that the total number of elements in the original\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
795 "matrix must match the total number of elements in the new matrix.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
796 "@end deftypefn\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
797 "@seealso{`:' and do_fortran_indexing}")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
798 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
799 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
800 int nargin = args.length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
801
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
802 if (nargin != 2 && nargin !=3) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
803 error("freshape (a, m, m) or freshape (a, size(b))");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
804 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
805 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
806 int mr = 0, mc = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
807 if (nargin == 2) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
808 RowVector tmp = args(1).row_vector_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
809 if (tmp.length() != 2)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
810 error("freshape: called with 2 args, second must be 2-element vector");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
811 mr = (int)tmp(0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
812 mc = (int)tmp(1);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
813 } else if (nargin == 3) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
814 mr = args(1).nint_value ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
815 mc = args(2).nint_value ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
816 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
817 if (args(0).is_scalar_type())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
818 if (mr != 1 || mc != 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
819 error("freshape: sizes must match");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
820 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
821 retval = args(0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
822 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
823 if (args(0).is_complex_type()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
824 if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
825 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
826 octave_fixed_complex_matrix::static_type_id ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
827 FixedComplexMatrix a = ((const octave_fixed_complex_matrix&)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
828 args(0).get_rep()).fixed_complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
829 int nr = a.rows();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
830 int nc = a.cols();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
831 if ((nr * nc) != (mr * mc))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
832 error("freshape: sizes must match");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
833 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
834 FixedComplexRowVector tmp1(mr*mc);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
835 for (int i=0;i<nr;i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
836 for (int j=0;j<nc;j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
837 tmp1(i+j*nr) = a(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
838 FixedComplexMatrix tmp2(mr,mc);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
839 for (int i=0;i<mr;i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
840 for (int j=0;j<mc;j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
841 tmp2(i,j) = tmp1(i+j*mr);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
842 retval = new octave_fixed_complex_matrix(tmp2);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
843 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
844 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
845 gripe_wrong_type_arg ("freshape", args(0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
846 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
847 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
848 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
849 if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
850 (args(0).type_id () == octave_fixed_matrix::static_type_id ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
851 FixedMatrix a = ((const octave_fixed_matrix&) args(0).get_rep()).
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
852 fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
853 int nr = a.rows();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
854 int nc = a.cols();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
855 if ((nr * nc) != (mr * mc))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
856 error("freshape: sizes must match");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
857 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
858 FixedRowVector tmp1(mr*mc);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
859 for (int i=0;i<nr;i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
860 for (int j=0;j<nc;j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
861 tmp1(i+j*nr) = a(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
862 FixedMatrix tmp2(mr,mc);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
863 for (int i=0;i<mr;i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
864 for (int j=0;j<mc;j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
865 tmp2(i,j) = tmp1(i+j*mr);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
866 retval = new octave_fixed_matrix(tmp2);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
867 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
868 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
869 gripe_wrong_type_arg ("freshape", args(0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
870 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
871 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
872 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
873 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
874 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
875 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
876 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
877
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
878 static octave_value
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
879 make_fdiag (const octave_value& a, const octave_value& b)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
880 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
881 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
882
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
883 if (fixed_type_loaded) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
884 if (a.is_complex_type() && ((a.type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
885 octave_fixed_complex::static_type_id ()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
886 (a.type_id () == octave_fixed_complex_matrix::static_type_id ()))) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
887 FixedComplexMatrix m;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
888 if (a.type_id () == octave_fixed_complex_matrix::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
889 m = ((const octave_fixed_complex_matrix&) a.get_rep())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
890 .fixed_complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
891 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
892 m = ((const octave_fixed_complex&) a.get_rep())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
893 .fixed_complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
894
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
895 int k = b.nint_value(true);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
896
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
897 if (! error_state) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
898 int nr = m.rows ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
899 int nc = m.columns ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
900
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
901 if (nr == 0 || nc == 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
902 retval = new octave_fixed_complex_matrix (m);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
903 else if (nr == 1 || nc == 1) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
904 int roff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
905 int coff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
906 if (k > 0) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
907 roff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
908 coff = k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
909 } else if (k < 0) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
910 k = -k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
911 roff = k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
912 coff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
913 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
914
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
915 // Try to be a bit intelligent about the representation of the zeros
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
916 bool same = true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
917 Complex is = m(0,0).getintsize();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
918 Complex ds = m(0,0).getdecsize();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
919 for (int j = 0; j < nc; j++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
920 for (int i = 0; i < nr; i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
921 if ((is != m(i,j).getintsize()) || (ds != m(i,j).getdecsize())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
922 same = false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
923 break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
924 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
925 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
926 if (!same) break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
927 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
928
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
929
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
930 if (nr == 1) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
931 int n = nc + k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
932 FixedComplexMatrix r;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
933 if (same)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
934 r.resize(n,n,FixedPointComplex(is,ds));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
935 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
936 r.resize(n,n);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
937 for (int i = 0; i < nc; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
938 r (i+roff, i+coff) = m (0, i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
939 retval = new octave_fixed_complex_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
940 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
941 int n = nr + k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
942 FixedComplexMatrix r;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
943 if (same)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
944 r.resize(n,n,FixedPointComplex(is,ds));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
945 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
946 r.resize(n,n);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
947 for (int i = 0; i < nr; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
948 r (i+roff, i+coff) = m (i, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
949 retval = new octave_fixed_complex_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
950 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
951 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
952 FixedComplexColumnVector r = m.diag (k);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
953 if (r.capacity () > 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
954 retval = new octave_fixed_complex_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
955 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
956 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
957 } else if ((a.type_id () == octave_fixed::static_type_id ()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
958 (a.type_id () == octave_fixed_matrix::static_type_id ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
959 FixedMatrix m;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
960 if (a.type_id () == octave_fixed_matrix::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
961 m = ((const octave_fixed_matrix&) a.get_rep()).fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
962 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
963 m = ((const octave_fixed&) a.get_rep()).fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
964
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
965 int k = b.nint_value(true);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
966
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
967 if (! error_state) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
968 int nr = m.rows ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
969 int nc = m.columns ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
970
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
971 if (nr == 0 || nc == 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
972 retval = new octave_fixed_matrix (m);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
973 else if (nr == 1 || nc == 1) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
974 int roff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
975 int coff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
976 if (k > 0) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
977 roff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
978 coff = k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
979 } else if (k < 0) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
980 k = -k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
981 roff = k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
982 coff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
983 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
984
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
985 // Try to be a bit intelligent about the representation of the zeros
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
986 bool same = true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
987 int is = m(0,0).getintsize();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
988 int ds = m(0,0).getdecsize();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
989 for (int j = 0; j < nc; j++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
990 for (int i = 0; i < nr; i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
991 if ((is != m(i,j).getintsize()) || (ds != m(i,j).getdecsize())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
992 same = false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
993 break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
994 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
995 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
996 if (!same) break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
997 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
998
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
999 if (nr == 1) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1000 int n = nc + k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1001 FixedMatrix r;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1002 if (same)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1003 r.resize(n,n,FixedPoint(is,ds));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1004 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1005 r.resize(n,n);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1006 for (int i = 0; i < nc; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1007 r (i+roff, i+coff) = m (0, i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1008 retval = new octave_fixed_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1009 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1010 int n = nr + k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1011 FixedMatrix r;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1012 if (same)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1013 r.resize(n,n,FixedPoint(is,ds));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1014 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1015 r.resize(n,n);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1016 for (int i = 0; i < nr; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1017 r (i+roff, i+coff) = m (i, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1018 retval = new octave_fixed_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1019 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1020 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1021 FixedColumnVector r = m.diag (k);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1022 if (r.capacity () > 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1023 retval = new octave_fixed_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1024 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1025 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1026 } else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1027 gripe_wrong_type_arg ("fdiag", a);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1028 } else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1029 gripe_wrong_type_arg ("fdiag", a);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1030 retval.maybe_mutate();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1031 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1032 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1033
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1034 // PKG_ADD: dispatch ("diag", "fdiag", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1035 // PKG_ADD: dispatch ("diag", "fdiag", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1036 // PKG_ADD: dispatch ("diag", "fdiag", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1037 // PKG_ADD: dispatch ("diag", "fdiag", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1038 DEFUN_DLD (fdiag, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1039 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1040 "@deftypefn {Loadable Function} {} fdiag (@var{v}, @var{k})\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1041 "Return a diagonal matrix with fixed point vector @var{v} on diagonal\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1042 "@var{k}. The second argument is optional. If it is positive, the vector is\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1043 "placed on the @var{k}-th super-diagonal. If it is negative, it is placed\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1044 "on the @var{-k}-th sub-diagonal. The default value of @var{k} is 0, and\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1045 "the vector is placed on the main diagonal. For example,\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1046 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1047 "@example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1048 "fdiag (fixed(3,2,[1, 2, 3]), 1)\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1049 "ans =\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1050 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1051 " 0.00 1.00 0.00 0.00\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1052 " 0.00 0.00 2.00 0.00\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1053 " 0.00 0.00 0.00 3.00\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1054 " 0.00 0.00 0.00 0.00\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1055 "@end example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1056 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1057 "Note that if all of the elements of the original vector have the same fixed\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1058 "point representation, then the zero elements in the matrix are created with\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1059 "the same representation. Otherwise the zero elements are created with the\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1060 "equivalent of the fixed point value @code{fixed(0,0,0)}.n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1061 "@end deftypefn\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1062 "@seealso{diag}")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1063 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1064 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1065
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1066 int nargin = args.length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1067
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1068 if (nargin == 1 && args(0).is_defined ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1069 retval = make_fdiag (args(0), octave_value(0.));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1070 else if (nargin == 2 && args(0).is_defined () && args(1).is_defined ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1071 retval = make_fdiag (args(0), args(1));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1072 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1073 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1074
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1075 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1076 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1077
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1078 // PKG_ADD: dispatch ("atan2", "fatan2", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1079 // PKG_ADD: dispatch ("atan2", "fatan2", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1080 // PKG_ADD: dispatch ("atan2", "fatan2", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1081 // PKG_ADD: dispatch ("atan2", "fatan2", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1082 DEFUN_DLD (fatan2, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1083 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1084 "@deftypefn {Loadable Function} {} fatan2 (@var{y}, @var{x})\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1085 "Compute atan (Y / X) for corresponding fixed point elements of Y and X.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1086 "The result is in range -pi to pi.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1087 "@end deftypefn\n")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1088 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1089 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1090 int nargin = args.length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1091 if (nargin == 2) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1092 FixedMatrix a, b;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1093 if (args(0).type_id () == octave_fixed::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1094 a = ((const octave_fixed&)args(0).get_rep()).fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1095 else if (args(0).type_id () == octave_fixed_matrix::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1096 a = ((const octave_fixed_matrix&)args(0).get_rep()).fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1097 else if (args(0).type_id () == octave_fixed_complex::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1098 a = ((const octave_fixed_complex&)args(0).get_rep())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1099 .fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1100 else if (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1101 octave_fixed_complex_matrix::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1102 a = ((const octave_fixed_complex_matrix&)args(0).get_rep())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1103 .fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1104 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1105 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1106 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1107 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1108 if (args(1).type_id () == octave_fixed::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1109 b = ((const octave_fixed&)args(1).get_rep()).fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1110 else if (args(1).type_id () == octave_fixed_matrix::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1111 b = ((const octave_fixed_matrix&)args(1).get_rep()).fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1112 else if (args(1).type_id () == octave_fixed_complex::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1113 b = ((const octave_fixed_complex&)args(1).get_rep())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1114 .fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1115 else if (args(1).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1116 octave_fixed_complex_matrix::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1117 b = ((const octave_fixed_complex_matrix&)args(1).get_rep())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1118 .fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1119 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1120 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1121 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1122 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1123 retval = new octave_fixed_matrix(atan2(a, b));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1124 retval.maybe_mutate();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1125 } else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1126 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1127
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1128 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1129 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1130
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1131 /*
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1132 ;;; Local Variables: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1133 ;;; mode: C++ ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1134 ;;; End: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1135 */