annotate main/fixed/src/fixed.cc @ 2383:d1930f8af7ca octave-forge

Changed the directory structure of fixed to match the package system
author hauberg
date Sun, 20 Aug 2006 14:43:38 +0000
parents
children 1728eb2120ef
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 extern void install_fil_fs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
59 extern void install_fil_fm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
60 extern void install_fil_fcs_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
61 extern void install_fil_fcm_ops (void);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
62
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
63 static bool fixed_type_loaded = false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
64
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
65 void load_fixed_type (void)
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 octave_fixed::register_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
68 octave_fixed_matrix::register_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
69 octave_fixed_complex::register_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
70 octave_fixed_complex_matrix::register_type ();
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_fs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
73 install_fs_fm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
74 install_fm_fs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
75 install_fm_fm_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_fs_fcs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
78 install_fs_fcm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
79 install_fm_fcs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
80 install_fm_fcm_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_fs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
83 install_fcs_fm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
84 install_fcm_fs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
85 install_fcm_fm_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 install_fcs_fcs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
88 install_fcs_fcm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
89 install_fcm_fcs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
90 install_fcm_fcm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
91
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
92 install_fil_fs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
93 install_fil_fm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
94 install_fil_fcs_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
95 install_fil_fcm_ops ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
96
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
97 fixed_type_loaded = true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
98
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
99 // Lock constructor function in place, otherwise
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
100 // "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
101 // 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
102 // for older versions of octave as well.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
103 fbi_sym_tab->lookup("fixed")->mark_as_static ();
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
106 DEFUN_DLD (display_fixed_operations, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
107 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
108 "@deftypefn {Loadable Function} {} display_fixed_operations ( )\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
109 "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
110 "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
111 "complexity of an algorithm.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
112 "@end deftypefn\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
113 "@seealso{fixed_point_count_operations, reset_fixed_operations}")
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 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
116 if ((args.length() != 0) || !fixed_type_loaded)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
117 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
118 else if (Fixed::FP_CountOperations)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
119 octave_stdout << Fixed::FP_Operations;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
120 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
121 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
122
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
123 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
124 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
125
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
126 DEFUN_DLD (reset_fixed_operations, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
127 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
128 "@deftypefn {Loadable Function} {} reset_fixed_operations ( )\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
129 "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
130 "@end deftypefn\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
131 "@seealso{fixed_point_count_operations, display_fixed_operations}")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
132 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
133 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
134 if ((args.length() != 0) || !fixed_type_loaded)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
135 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
136 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
137 Fixed::FP_Operations.reset();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
138
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
139 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
140 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
141
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
142 DEFUN_DLD (isfixed, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
143 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
144 "@deftypefn {Loadable Function} {} isfixed (@var{expr})\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
145 "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
146 "@end deftypefn")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
147 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
148 if (args.length() != 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
149 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
150 else if (!fixed_type_loaded)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
151 // 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
152 return octave_value(false);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
153 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
154 return (octave_value((args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
155 octave_fixed::static_type_id ()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
156 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
157 octave_fixed_matrix::static_type_id ()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
158 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
159 octave_fixed_complex::static_type_id ()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
160 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
161 octave_fixed_complex_matrix::static_type_id ())));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
162 return octave_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
163 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
164
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
165 DEFUN_DLD (fixed, args, nargout,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
166 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
167 "@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
168 "@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
169 "@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
170 "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
171 "@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
172 "@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
173 "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
174 "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
175 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
176 "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
177 "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
178 "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
179 "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
180 "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
181 "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
182 "@var{is} and @var{ds}.\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
183 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
184 "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
185 "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
186 "and @var{ds} are complex integers."
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
187 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
188 "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
189 "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
190 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
191 "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
192 "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
193 "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
194 "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
195 "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
196 "@end deftypefn\n")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
197 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
198 int nargin = args.length();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
199 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
200
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
201 if ( nargin == 0 ) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
202 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
203 } else if (nargin == 1 ) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
204 if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
205 (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
206 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
207 fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
208 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
209 } else if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
210 (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
211 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
212 retval = new octave_fixed (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
213 } else if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
214 (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
215 FixedPointComplex f = ((const octave_fixed_complex&)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
216 args(0).get_rep()).fixed_complex_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
217 retval = new octave_fixed_complex (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
218 } else if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
219 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
220 octave_fixed_complex_matrix::static_type_id ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
221 FixedComplexMatrix f = ((const octave_fixed_complex_matrix&)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
222 args(0).get_rep()).fixed_complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
223 retval = new octave_fixed_complex_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
224 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
225 if (args(0).is_complex_type()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
226 ComplexMatrix a = args(0).complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
227 MArray2<int> b(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
228 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
229 for (int i = 0; i < a.rows(); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
230 b(i,j) = (int)real(a(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
231 FixedMatrix fr(b);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
232 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
233 for (int i = 0; i < a.rows(); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
234 b(i,j) = (int)imag(a(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
235 FixedMatrix fi(b);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
236 retval = new octave_fixed_complex_matrix (fr, fi);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
237 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
238 Matrix a = args(0).matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
239 MArray2<int> b(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
240 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
241 for (int i = 0; i < a.rows(); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
242 b(i,j) = (int)a(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
243 FixedMatrix f(b);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
244 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
245 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
246 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
247 } else if ((nargin ==2) || (nargin == 3)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
248 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
249 ((nargin > 2) && args(2).is_complex_type())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
250
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
251 MArray2<int> mir, mii, mdr, mdi;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
252 ComplexMatrix a, b;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
253 if (args(0).is_complex_type())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
254 a = args(0).complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
255 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
256 a = ComplexMatrix(args(0).matrix_value());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
257 a = a + Complex(0.,1.)*a;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
258 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
259 if (args(1).is_complex_type())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
260 b = args(1).complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
261 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
262 b = ComplexMatrix(args(1).matrix_value());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
263 b = b + Complex(0.,1.)*b;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
264 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
265
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
266 mir.resize(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
267 mii.resize(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
268 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
269 for (int i = 0; i < a.rows(); i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
270 mir(i,j) = (int) real(a(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
271 mii(i,j) = (int) imag(a(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
272 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
273 (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
274 (mir(i,j) < 0) || (mii(i,j) < 0)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
275 error("fixed: invalid fixed point representation");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
276 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
277 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
278 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
279
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
280 mdr.resize(b.rows(),b.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
281 mdi.resize(b.rows(),b.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
282 for (int j = 0; j < b.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
283 for (int i = 0; i < b.rows(); i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
284 mdr(i,j) = (int) real(b(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
285 mdi(i,j) = (int) imag(b(i,j));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
286 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
287 (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
288 (mir(i,j) < 0) || (mdi(i,j) < 0)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
289 error("fixed: invalid fixed point representation");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
290 return retval;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
294 if ((mir.rows() == 1) && (mir.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
295 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
296 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
297 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
298 if ((mdr.rows() == 1) && (mdr.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
299 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
300 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
301 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
302
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
303 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
304 error("fixed: dimension mismatch in args");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
305 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
306 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
307
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
308 if (nargin == 2 ) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
309 if (!fixed_type_loaded) load_fixed_type();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
310 if ((mir.rows() == 1) && (mir.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
311 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
312 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
313 retval = new octave_fixed_complex (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
314 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
315 FixedComplexMatrix f (FixedMatrix (mir, mdr),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
316 FixedMatrix (mii, mdi));
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 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
319 } else if (nargin == 3) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
320 ComplexMatrix c = args(2).complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
321 if ((mir.rows() == 1) && (mir.cols() == 1)) {
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((int)mir(0,0), (int)mdr(0,0),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
324 real(c)),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
325 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
326 imag(c)));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
327 retval = new octave_fixed_complex_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
328 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
329 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
330 error("fixed: dimension mismatch in args");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
331 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
332 if (!fixed_type_loaded) load_fixed_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
333 FixedComplexMatrix f(FixedMatrix(mir, mdr, real(c)),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
334 FixedMatrix(mii, mdi, imag(c)));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
335 retval = new octave_fixed_complex_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
336 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
337 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
338 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
339 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
340 MArray2<int> mis, mds;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
341 Matrix a = args(0).matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
342 Matrix b = args(1).matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
343
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
344 mis.resize(a.rows(),a.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
345 for (int j = 0; j < a.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
346 for (int i = 0; i < a.rows(); i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
347 mis(i,j) = (int)a(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
348 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
349 error("fixed: invalid fixed point representation");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
350 return retval;
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 mds.resize(b.rows(),b.cols());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
354 for (int j=0; j < b.cols(); j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
355 for (int i=0; i < b.rows(); i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
356 mds(i,j) = (int)b(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
357 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
358 error("fixed: invalid fixed point representation");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
359 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
360 }
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 ((mis.rows() == 1) && (mis.cols() == 1))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
364 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
365 if ((mds.rows() == 1) && (mds.cols() == 1))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
366 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
367
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
368 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
369 error("fixed: dimension mismatch in args");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
370 return retval;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
373 if (nargin == 2 ) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
374 if (!fixed_type_loaded) load_fixed_type();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
375 if ((mis.rows() == 1) && (mis.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
376 FixedPoint f(mis(0,0), mds(0,0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
377 retval = new octave_fixed (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 FixedMatrix f(mis, mds);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
380 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
381 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
382 } else if (nargin == 3) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
383 Matrix a = args(2).matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
384 if ((mis.rows() == 1) && (mis.cols() == 1)) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
385 if (!fixed_type_loaded) load_fixed_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
386 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
387 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
388 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
389 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
390 error("fixed: dimension mismatch in args");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
391 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
392 if (!fixed_type_loaded) load_fixed_type ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
393 FixedMatrix f (mis, mds, a);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
394 retval = new octave_fixed_matrix (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
395 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
396 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
397 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
398 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
399 } else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
400 print_usage ();
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
403 if (error_state) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
404 error("fixed: failed to create fixed point number");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
405 return octave_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
406 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
407 retval.maybe_mutate();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
408 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
409 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
410 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
411
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
412 // 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
413 // of the function helps can take place!! The second DEFUN_DLD must NOT
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
414 // appear on a new-line, otherwise the idnexing script will be confused!!
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
415 #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
416 REAL_CAN_RET_CMPLX_UPPER,UPPER, REAL_CAN_RET_CMPLX_LOWER, \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
417 LOWER) DEFUN_DLD ( NAME, args, nargout, HELP) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
418 { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
419 int nargin = args.length(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
420 octave_value retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
421 if ( nargin != 1 ) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
422 print_usage (); \
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 if (fixed_type_loaded) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
425 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
426 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
427 .fixed_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
428 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
429 (REAL_CAN_RET_CMPLX_LOWER && (f.fixedpoint() < LOWER))) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
430 retval = new octave_fixed_complex \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
431 (FUNC (FixedPointComplex(f,FixedPoint(f.getintsize(), \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
432 f.getdecsize())))); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
433 else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
434 retval = new octave_fixed (FUNC (f)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
435 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
436 octave_fixed_matrix::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
437 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
438 .fixed_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
439 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
440 > UPPER)) || \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
441 (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
442 < LOWER))) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
443 retval = new octave_fixed_complex_matrix \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
444 (FUNC (FixedComplexMatrix(f))); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
445 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
446 retval = new octave_fixed_matrix (FUNC (f)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
447 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
448 octave_fixed_complex::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
449 FixedPointComplex f = ((const octave_fixed_complex&) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
450 args(0).get_rep()).fixed_complex_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
451 retval = new octave_fixed_complex (FUNC (f)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
452 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
453 octave_fixed_complex_matrix::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
454 FixedComplexMatrix f = ((const octave_fixed_complex_matrix&) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
455 args(0).get_rep()).fixed_complex_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
456 retval = new octave_fixed_complex_matrix (FUNC (f)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
457 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
458 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
459 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
460 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
461 } \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
462 retval.maybe_mutate(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
463 return retval; \
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
466 // PKG_ADD: dispatch ("real", "freal", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
467 // PKG_ADD: dispatch ("real", "freal", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
468 // PKG_ADD: dispatch ("real", "freal", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
469 // PKG_ADD: dispatch ("real", "freal", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
470 DEFUN_DLD_FIXED_SNGL_ARG (freal, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
471 @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
472 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
473 @end deftypefn", ::real, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
474
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
475 // PKG_ADD: dispatch ("imag", "fimag", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
476 // PKG_ADD: dispatch ("imag", "fimag", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
477 // PKG_ADD: dispatch ("imag", "fimag", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
478 // PKG_ADD: dispatch ("imag", "fimag", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
479 DEFUN_DLD_FIXED_SNGL_ARG (fimag, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
480 @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
481 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
482 @end deftypefn", ::imag, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
483
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
484 // PKG_ADD: dispatch ("conj", "fconj", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
485 // PKG_ADD: dispatch ("conj", "fconj", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
486 // PKG_ADD: dispatch ("conj", "fconj", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
487 // PKG_ADD: dispatch ("conj", "fconj", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
488 DEFUN_DLD_FIXED_SNGL_ARG (fconj, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
489 @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
490 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
491 @end deftypefn", ::conj, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
492
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
493 // PKG_ADD: dispatch ("abs", "fabs", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
494 // PKG_ADD: dispatch ("abs", "fabs", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
495 // PKG_ADD: dispatch ("abs", "fabs", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
496 // PKG_ADD: dispatch ("abs", "fabs", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
497 DEFUN_DLD_FIXED_SNGL_ARG (fabs, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
498 @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
499 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
500 @end deftypefn", ::abs, 0, 0, 0, 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
501
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
502 // PKG_ADD: dispatch ("arg", "farg", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
503 // PKG_ADD: dispatch ("arg", "farg", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
504 // PKG_ADD: dispatch ("arg", "farg", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
505 // PKG_ADD: dispatch ("arg", "farg", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
506 DEFUN_DLD_FIXED_SNGL_ARG (farg, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
507 @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
508 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
509 @iftex\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
510 @tex\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
511 $\\theta = atan2( y , x)$\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
512 @end tex\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
513 @end iftex\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
514 @ifinfo\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
515 @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
516 @end ifinfo\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
517 in radians. For example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
518 \n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
519 @example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
520 @group\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
521 farg (fixed (3,5,3+4i))\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
522 @result{} 0.90625\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
523 @end group\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
524 @end example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
525 @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
526
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
527 // PKG_ADD: dispatch ("angle", "fangle", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
528 // PKG_ADD: dispatch ("angle", "fangle", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
529 // PKG_ADD: dispatch ("angle", "fangle", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
530 // PKG_ADD: dispatch ("angle", "fangle", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
531 DEFUN_DLD_FIXED_SNGL_ARG (fangle, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
532 @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
533 See @dfn{farg}.\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
534 @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
535
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
536 // PKG_ADD: dispatch ("cos", "fcos", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
537 // PKG_ADD: dispatch ("cos", "fcos", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
538 // PKG_ADD: dispatch ("cos", "fcos", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
539 // PKG_ADD: dispatch ("cos", "fcos", "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 (fcos, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
541 @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
542 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
543 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
544 @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
545
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
546 // PKG_ADD: dispatch ("cosh", "fcosh", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
547 // PKG_ADD: dispatch ("cosh", "fcosh", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
548 // PKG_ADD: dispatch ("cosh", "fcosh", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
549 // PKG_ADD: dispatch ("cosh", "fcosh", "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 (fcosh, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
551 @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
552 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
553 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
554 @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
555
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
556 // PKG_ADD: dispatch ("sin", "fsin", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
557 // PKG_ADD: dispatch ("sin", "fsin", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
558 // PKG_ADD: dispatch ("sin", "fsin", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
559 // PKG_ADD: dispatch ("sin", "fsin", "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 (fsin, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
561 @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
562 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
563 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
564 @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
565
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
566 // PKG_ADD: dispatch ("sinh", "fsinh", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
567 // PKG_ADD: dispatch ("sinh", "fsinh", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
568 // PKG_ADD: dispatch ("sinh", "fsinh", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
569 // PKG_ADD: dispatch ("sinh", "fsinh", "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 (fsinh, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
571 @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
572 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
573 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
574 @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
575
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
576 // PKG_ADD: dispatch ("tan", "ftan", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
577 // PKG_ADD: dispatch ("tan", "ftan", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
578 // PKG_ADD: dispatch ("tan", "ftan", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
579 // PKG_ADD: dispatch ("tan", "ftan", "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 (ftan, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
581 @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
582 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
583 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
584 @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
585
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
586 // PKG_ADD: dispatch ("tanh", "ftanh", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
587 // PKG_ADD: dispatch ("tanh", "ftanh", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
588 // PKG_ADD: dispatch ("tanh", "ftanh", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
589 // PKG_ADD: dispatch ("tanh", "ftanh", "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 (ftanh, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
591 @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
592 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
593 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
594 @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
595
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
596 // PKG_ADD: dispatch ("sqrt", "fsqrt", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
597 // PKG_ADD: dispatch ("sqrt", "fsqrt", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
598 // PKG_ADD: dispatch ("sqrt", "fsqrt", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
599 // PKG_ADD: dispatch ("sqrt", "fsqrt", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
600 DEFUN_DLD_FIXED_SNGL_ARG (fsqrt, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
601 @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
602 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
603 @end deftypefn", ::sqrt, 0, 0, 1, FixedPoint());
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 ("exp", "fexp", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
606 // PKG_ADD: dispatch ("exp", "fexp", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
607 // PKG_ADD: dispatch ("exp", "fexp", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
608 // PKG_ADD: dispatch ("exp", "fexp", "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 (fexp, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
610 @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
611 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
612 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
613 @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
614
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
615 // PKG_ADD: dispatch ("log", "flog", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
616 // PKG_ADD: dispatch ("log", "flog", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
617 // PKG_ADD: dispatch ("log", "flog", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
618 // PKG_ADD: dispatch ("log", "flog", "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 (flog, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
620 @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
621 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
622 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
623 @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
624
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
625 // PKG_ADD: dispatch ("log10", "flog10", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
626 // PKG_ADD: dispatch ("log10", "flog10", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
627 // PKG_ADD: dispatch ("log10", "flog10", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
628 // PKG_ADD: dispatch ("log10", "flog10", "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 (flog10, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
630 @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
631 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
632 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
633 @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
634
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
635 // PKG_ADD: dispatch ("round", "fround", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
636 // PKG_ADD: dispatch ("round", "fround", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
637 // PKG_ADD: dispatch ("round", "fround", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
638 // PKG_ADD: dispatch ("round", "fround", "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 (fround, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
640 @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
641 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
642 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
643 @seealso{ffloor, fceil}", ::round, 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 ("floor", "ffloor", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
646 // PKG_ADD: dispatch ("floor", "ffloor", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
647 // PKG_ADD: dispatch ("floor", "ffloor", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
648 // PKG_ADD: dispatch ("floor", "ffloor", "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 (ffloor, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
650 @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
651 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
652 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
653 @seealso{fround, fceil}", ::floor, 0, 0, 0, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
654
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
655 // PKG_ADD: dispatch ("ceil", "fceil", "fixed scalar")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
656 // PKG_ADD: dispatch ("ceil", "fceil", "fixed matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
657 // PKG_ADD: dispatch ("ceil", "fceil", "fixed complex")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
658 // PKG_ADD: dispatch ("ceil", "fceil", "fixed complex matrix")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
659 DEFUN_DLD_FIXED_SNGL_ARG (fceil, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
660 @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
661 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
662 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
663 @seealso{fround, ffloor}", ::ceil, 0, 0, 0, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
664
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
665 #define DEFUN_DLD_FIXED_DIM_ARG(NAME, HELP, FUNC) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
666 DEFUN_DLD ( NAME, args, nargout, HELP) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
667 { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
668 int nargin = args.length(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
669 octave_value retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
670 if ((nargin != 1 ) && (nargin != 2)) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
671 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
672 else { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
673 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
674 if (error_state) return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
675 if (dim < -1 || dim > 1) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
676 error (#NAME ": invalid dimension argument = %d", dim + 1); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
677 return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
678 } \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
679 if (fixed_type_loaded) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
680 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
681 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
682 .fixed_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
683 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
684 } 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
685 static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
686 FixedComplexMatrix f = ((const octave_fixed_complex&) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
687 args(0).get_rep()).fixed_complex_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
688 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
689 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
690 octave_fixed_matrix::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
691 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
692 .fixed_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
693 retval = new octave_fixed_matrix(f .FUNC (dim)); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
694 } else if (args(0).type_id () == \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
695 octave_fixed_complex_matrix::static_type_id ()) { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
696 FixedComplexMatrix f = ((const octave_fixed_complex_matrix&) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
697 args(0).get_rep()).fixed_complex_matrix_value (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
698 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
699 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
700 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
701 } else \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
702 print_usage (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
703 } \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
704 retval.maybe_mutate(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
705 return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
706 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
707
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
708 // PKG_ADD: dispatch ("prod", "fprod", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
709 // PKG_ADD: dispatch ("prod", "fprod", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
710 // PKG_ADD: dispatch ("prod", "fprod", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
711 // PKG_ADD: dispatch ("prod", "fprod", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
712 DEFUN_DLD_FIXED_DIM_ARG (fprod, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
713 @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
714 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
715 it defaults to 1 (column-wise products).\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
716 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
717 @seealso{fsum, fsumsq}", prod)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
718
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
719 // PKG_ADD: dispatch ("cumprod", "fcumprod", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
720 // PKG_ADD: dispatch ("cumprod", "fcumprod", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
721 // PKG_ADD: dispatch ("cumprod", "fcumprod", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
722 // PKG_ADD: dispatch ("cumprod", "fcumprod", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
723 DEFUN_DLD_FIXED_DIM_ARG (fcumprod, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
724 @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
725 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
726 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
727 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
728 @seealso{fcumsum}", cumprod)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
729
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
730 // PKG_ADD: dispatch ("sum", "fsum", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
731 // PKG_ADD: dispatch ("sum", "fsum", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
732 // PKG_ADD: dispatch ("sum", "fsum", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
733 // PKG_ADD: dispatch ("sum", "fsum", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
734 DEFUN_DLD_FIXED_DIM_ARG (fsum, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
735 @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
736 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
737 defaults to 1 (column-wise sum).\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
738 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
739 @seealso{fprod, fsumsq}", sum)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
740
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
741 // PKG_ADD: dispatch ("cumsum", "fcumsum", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
742 // PKG_ADD: dispatch ("cumsum", "fcumsum", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
743 // PKG_ADD: dispatch ("cumsum", "fcumsum", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
744 // PKG_ADD: dispatch ("cumsum", "fcumsum", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
745 DEFUN_DLD_FIXED_DIM_ARG (fcumsum, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
746 @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
747 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
748 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
749 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
750 @seealso{fcumprod}", cumsum)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
751
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
752 // PKG_ADD: dispatch ("sumsq", "fsumsq", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
753 // PKG_ADD: dispatch ("sumsq", "fsumsq", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
754 // PKG_ADD: dispatch ("sumsq", "fsumsq", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
755 // PKG_ADD: dispatch ("sumsq", "fsumsq", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
756 DEFUN_DLD_FIXED_DIM_ARG (fsumsq, "-*- texinfo -*-\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
757 @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
758 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
759 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
760 This function is equivalent to computing\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
761 @example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
762 fsum (x .* fconj (x), dim)\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
763 @end example\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
764 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
765 @end deftypefn\n\
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
766 @seealso{fprod, fsum}", sumsq)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
767
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
768 // PKG_ADD: dispatch ("reshape", "freshape", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
769 // PKG_ADD: dispatch ("reshape", "freshape", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
770 // PKG_ADD: dispatch ("reshape", "freshape", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
771 // PKG_ADD: dispatch ("reshape", "freshape", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
772 DEFUN_DLD (freshape, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
773 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
774 "@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
775 "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
776 "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
777 "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
778 "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
779 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
780 "For 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 "@example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
783 "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
784 "ans =\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
785 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
786 " 1.00 3.00\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
787 " 2.00 4.00\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
788 "@end example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
789 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
790 "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
791 "@code{freshape} function is equivalent to\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
792 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
793 "@example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
794 "@group\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
795 "retval = fixed(0,0,zeros (m, n));\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
796 "retval (:) = a;\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
797 "@end group\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
798 "@end example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
799 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
800 "@noindent\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
801 "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
802 "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
803 "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
804 "@end deftypefn\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
805 "@seealso{`:' and do_fortran_indexing}")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
806 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
807 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
808 int nargin = args.length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
809
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
810 if (nargin != 2 && nargin !=3) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
811 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
812 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
813 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
814 int mr = 0, mc = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
815 if (nargin == 2) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
816 RowVector tmp = args(1).row_vector_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
817 if (tmp.length() != 2)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
818 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
819 mr = (int)tmp(0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
820 mc = (int)tmp(1);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
821 } else if (nargin == 3) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
822 mr = args(1).nint_value ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
823 mc = args(2).nint_value ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
824 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
825 if (args(0).is_scalar_type())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
826 if (mr != 1 || mc != 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
827 error("freshape: sizes must match");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
828 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
829 retval = args(0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
830 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
831 if (args(0).is_complex_type()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
832 if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
833 (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
834 octave_fixed_complex_matrix::static_type_id ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
835 FixedComplexMatrix a = ((const octave_fixed_complex_matrix&)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
836 args(0).get_rep()).fixed_complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
837 int nr = a.rows();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
838 int nc = a.cols();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
839 if ((nr * nc) != (mr * mc))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
840 error("freshape: sizes must match");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
841 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
842 FixedComplexRowVector tmp1(mr*mc);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
843 for (int i=0;i<nr;i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
844 for (int j=0;j<nc;j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
845 tmp1(i+j*nr) = a(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
846 FixedComplexMatrix tmp2(mr,mc);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
847 for (int i=0;i<mr;i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
848 for (int j=0;j<mc;j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
849 tmp2(i,j) = tmp1(i+j*mr);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
850 retval = new octave_fixed_complex_matrix(tmp2);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
851 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
852 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
853 gripe_wrong_type_arg ("freshape", args(0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
854 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
855 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
856 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
857 if (fixed_type_loaded &&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
858 (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
859 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
860 fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
861 int nr = a.rows();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
862 int nc = a.cols();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
863 if ((nr * nc) != (mr * mc))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
864 error("freshape: sizes must match");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
865 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
866 FixedRowVector tmp1(mr*mc);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
867 for (int i=0;i<nr;i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
868 for (int j=0;j<nc;j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
869 tmp1(i+j*nr) = a(i,j);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
870 FixedMatrix tmp2(mr,mc);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
871 for (int i=0;i<mr;i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
872 for (int j=0;j<mc;j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
873 tmp2(i,j) = tmp1(i+j*mr);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
874 retval = new octave_fixed_matrix(tmp2);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
875 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
876 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
877 gripe_wrong_type_arg ("freshape", args(0));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
878 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
879 }
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 }
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 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
884 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
885
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
886 static octave_value
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
887 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
888 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
889 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
890
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
891 if (fixed_type_loaded) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
892 if (a.is_complex_type() && ((a.type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
893 octave_fixed_complex::static_type_id ()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
894 (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
895 FixedComplexMatrix m;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
896 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
897 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
898 .fixed_complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
899 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
900 m = ((const octave_fixed_complex&) a.get_rep())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
901 .fixed_complex_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
902
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
903 int k = b.nint_value(true);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
904
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
905 if (! error_state) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
906 int nr = m.rows ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
907 int nc = m.columns ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
908
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
909 if (nr == 0 || nc == 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
910 retval = new octave_fixed_complex_matrix (m);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
911 else if (nr == 1 || nc == 1) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
912 int roff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
913 int coff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
914 if (k > 0) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
915 roff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
916 coff = k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
917 } else if (k < 0) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
918 k = -k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
919 roff = k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
920 coff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
921 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
922
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
923 // 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
924 bool same = true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
925 Complex is = m(0,0).getintsize();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
926 Complex ds = m(0,0).getdecsize();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
927 for (int j = 0; j < nc; j++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
928 for (int i = 0; i < nr; i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
929 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
930 same = false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
931 break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
932 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
933 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
934 if (!same) break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
935 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
936
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
937
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
938 if (nr == 1) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
939 int n = nc + k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
940 FixedComplexMatrix r;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
941 if (same)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
942 r.resize(n,n,FixedPointComplex(is,ds));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
943 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
944 r.resize(n,n);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
945 for (int i = 0; i < nc; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
946 r (i+roff, i+coff) = m (0, i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
947 retval = new octave_fixed_complex_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
948 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
949 int n = nr + k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
950 FixedComplexMatrix r;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
951 if (same)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
952 r.resize(n,n,FixedPointComplex(is,ds));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
953 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
954 r.resize(n,n);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
955 for (int i = 0; i < nr; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
956 r (i+roff, i+coff) = m (i, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
957 retval = new octave_fixed_complex_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
958 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
959 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
960 FixedComplexColumnVector r = m.diag (k);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
961 if (r.capacity () > 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
962 retval = new octave_fixed_complex_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
963 }
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 } 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
966 (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
967 FixedMatrix m;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
968 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
969 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
970 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
971 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
972
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
973 int k = b.nint_value(true);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
974
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
975 if (! error_state) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
976 int nr = m.rows ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
977 int nc = m.columns ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
978
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
979 if (nr == 0 || nc == 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
980 retval = new octave_fixed_matrix (m);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
981 else if (nr == 1 || nc == 1) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
982 int roff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
983 int coff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
984 if (k > 0) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
985 roff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
986 coff = k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
987 } else if (k < 0) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
988 k = -k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
989 roff = k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
990 coff = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
991 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
992
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
993 // 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
994 bool same = true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
995 int is = m(0,0).getintsize();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
996 int ds = m(0,0).getdecsize();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
997 for (int j = 0; j < nc; j++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
998 for (int i = 0; i < nr; i++) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
999 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
1000 same = false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1001 break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1002 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1003 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1004 if (!same) break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1005 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1006
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1007 if (nr == 1) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1008 int n = nc + k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1009 FixedMatrix r;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1010 if (same)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1011 r.resize(n,n,FixedPoint(is,ds));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1012 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1013 r.resize(n,n);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1014 for (int i = 0; i < nc; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1015 r (i+roff, i+coff) = m (0, i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1016 retval = new octave_fixed_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1017 } else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1018 int n = nr + k;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1019 FixedMatrix r;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1020 if (same)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1021 r.resize(n,n,FixedPoint(is,ds));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1022 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1023 r.resize(n,n);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1024 for (int i = 0; i < nr; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1025 r (i+roff, i+coff) = m (i, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1026 retval = new octave_fixed_matrix (r);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1027 }
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 FixedColumnVector r = m.diag (k);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1030 if (r.capacity () > 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1031 retval = new octave_fixed_matrix (r);
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 } else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1035 gripe_wrong_type_arg ("fdiag", a);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1036 } else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1037 gripe_wrong_type_arg ("fdiag", a);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1038 retval.maybe_mutate();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1039 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1040 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1041
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1042 // PKG_ADD: dispatch ("diag", "fdiag", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1043 // PKG_ADD: dispatch ("diag", "fdiag", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1044 // PKG_ADD: dispatch ("diag", "fdiag", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1045 // PKG_ADD: dispatch ("diag", "fdiag", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1046 DEFUN_DLD (fdiag, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1047 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1048 "@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
1049 "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
1050 "@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
1051 "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
1052 "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
1053 "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
1054 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1055 "@example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1056 "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
1057 "ans =\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1058 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1059 " 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
1060 " 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
1061 " 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
1062 " 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
1063 "@end example\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1064 "\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1065 "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
1066 "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
1067 "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
1068 "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
1069 "@end deftypefn\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1070 "@seealso{diag}")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1071 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1072 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1073
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1074 int nargin = args.length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1075
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1076 if (nargin == 1 && args(0).is_defined ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1077 retval = make_fdiag (args(0), octave_value(0.));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1078 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
1079 retval = make_fdiag (args(0), args(1));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1080 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1081 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1082
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1083 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1084 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1085
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1086 // PKG_ADD: dispatch ("atan2", "fatan2", "fixed scalar");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1087 // PKG_ADD: dispatch ("atan2", "fatan2", "fixed matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1088 // PKG_ADD: dispatch ("atan2", "fatan2", "fixed complex");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1089 // PKG_ADD: dispatch ("atan2", "fatan2", "fixed complex matrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1090 DEFUN_DLD (fatan2, args, ,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1091 "-*- texinfo -*-\n"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1092 "@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
1093 "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
1094 "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
1095 "@end deftypefn\n")
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1096 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1097 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1098 int nargin = args.length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1099 if (nargin == 2) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1100 FixedMatrix a, b;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1101 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
1102 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
1103 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
1104 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
1105 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
1106 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
1107 .fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1108 else if (args(0).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1109 octave_fixed_complex_matrix::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1110 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
1111 .fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1112 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1113 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1114 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1115 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1116 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
1117 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
1118 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
1119 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
1120 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
1121 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
1122 .fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1123 else if (args(1).type_id () ==
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1124 octave_fixed_complex_matrix::static_type_id ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1125 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
1126 .fixed_matrix_value();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1127 else {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1128 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1129 return retval;
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 retval = new octave_fixed_matrix(atan2(a, b));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1132 retval.maybe_mutate();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1133 } else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1134 print_usage ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1135
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1136 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1137 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1138
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1139 /*
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1140 ;;; Local Variables: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1141 ;;; mode: C++ ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1142 ;;; End: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
1143 */