1 This is fixed.info, produced by makeinfo version 4.11 from fixed.texi.
4 File: fixed.info, Node: Top, Next: Basics
6 Fixed Point Toolbox for Octave
7 ******************************
11 * Basics:: The basics of the fixed point types
12 * Programming:: Using the fixed-point type in C++ and oct-files
13 * Example:: Fixed point type applied to real signal processing example
14 * Function Reference:: Documentation from the fixed point specific functions
17 File: fixed.info, Node: Basics, Next: Programming, Prev: Top, Up: Top
19 1 The Basics of the Fixed Point Types
20 *************************************
22 When implementing algorithms in hardware, it is common to reduce the
23 accuracy of the representation of numbers to a smaller number of bits.
24 This allows much lower complexity in the hardware, at the cost of
25 accuracy and potential overflow problems. Such representations are
28 This toolbox supplies a fixed point type that allows Octave to model
29 the effects of such a reduction in accuracy of the representation of
30 numbers. The major advantage of this toolbox is that with correctly
31 written Octave scripts, the same code can be used to test both fixed
32 and floating point representations of numbers.
34 The authors have tried to take all care to ensure the correct
35 functionality of this package. However, as this code is relatively
36 recent we expect that there will be a certain number of problems. We
37 welcome all reports of bugs, etc or even success stories. The authors
38 can be contacted at the e-mail address <David.Bateman@motorola.com>.
42 * License:: The License used with this Package
43 * Representation:: Representation of fixed point numbers
44 * Creation:: Creation of fixed point numbers
45 * Overflow:: Overflow Behavior of Fixed Point Numbers
46 * Built-in Variables:: Fixed Point Built-in Variables
47 * Accessing Internal Fields:: The properties of fixed point numbers
48 * Function Overloading:: Fixed point numbers with existing Octave functions
49 * Together:: Putting it all together
50 * Precision:: Problems of precision in calculations
51 * Lookup Tables:: The use of Lookup tables with fixed point values;
52 * Known Problems:: Read this before reporting a bug
55 File: fixed.info, Node: License, Next: Representation, Prev: Basics, Up: Basics
57 1.1 The License used with this Package
58 ======================================
60 The license used with this package is the GNU General Public License, a
61 copy of which is distributed with this package in the file `COPYING'.
62 Some commercial users have seemed quite concerned about the use of
63 software licensed under the GPL in their development. To ease these
64 concerns, the authors state in clear English the terms of the GPL allow
67 1. Any algorithm developed with this package remains the sole property
68 of the party developing the algorithm.
70 2. Changes can be made to the fixed point package, with the
71 constraint that if you supply a version of the fixed point package
72 to another party it must equally be covered by the terms of the
75 We believe that there is little reason to make proprietary changes to
76 the fixed point package itself. So this clear distinction between the
77 fixed point code itself and algorithms developed with it means that
78 there should be little concern for a use of this package in the
79 development of a proprietary algorithms.
81 Proprietary changes to the fixed point package itself are possible.
82 The GPL only comes into play in if you distribute the fixed point
83 package with these changes. The algorithms developed on these modified
84 versions of the fixed point package remain proprietary in all cases.
87 File: fixed.info, Node: Representation, Next: Creation, Prev: License, Up: Basics
89 1.2 Fixed Point Representation
90 ==============================
92 Fixed point numbers can be represented digitally in several manners,
93 including _sign-magnitude_, _ones-complement_ and _twos-complement_.
94 The most commonly used technique is _twos-complement_ due to the easier
95 implementation of certain operations in this representation. As such
96 this toolbox uses the _twos-complement_ representation of numbers
98 All fixed point objects in this toolbox are represented by an _int_
99 that is used in the following manner
101 1 bit representing the sign,
103 IS bits representing the integer part of the number, and
105 DS bits representing the decimal part of the number.
107 The numbers that can then be represented are then given by
109 - 2 ^ IS <= X <= 2 ^IS -1
111 and the distance between two values of X that are not represented by
112 the same fixed point value is 2 ^ (-DS) .
114 The number of bits that can be used in the representation of the
115 fixed point objects is determined by the number of bits in an _int_ on
116 the platform. Valid values include 32- and 64-bits. To avoid issues with
117 overflows in additions, one of these bits can not be used. Therefore
118 valid values of IS and DS are given by
120 0 < ( IS + DS ) < N - 2
122 where N is either 32 or 64, depending on the number of bits in an
123 _int_. It should be noted that given the above criteria it is possible
124 to create a fixed point representation that lacks a representation of
125 the number 1. This makes the implementation of certain operators
126 difficult, and so the valid representations are further limited to
128 0 < ( IS, DS, IS + DS ) < N - 2
130 This does not mean that other numbers can not be represented by this
131 toolbox, but rather that the numbers must be scaled prior to their
134 This toolbox allows both fixed point real and complex scalars to be
135 represented, as well as fixed point real and complex matrices. The real
136 and imaginary parts of the fixed point number and each element of a
137 fixed point matrix has its own fixed point representation.
140 File: fixed.info, Node: Creation, Next: Overflow, Prev: Representation, Up: Basics
142 1.3 Creating Fixed Point Numbers
143 ================================
145 Before using a fixed point type, some variables must be created that
146 use this type. This is done with the function "fixed". The function
147 "fixed" can be used in several manners, depending on the number and
148 type of the arguments that are given. It can be used to create scalar,
149 complex, matrix and complex matrix values of the fixed type.
151 The generic call to "fixed" is `fixed(IS,DS,F)', where the variables
155 The number of bits to use in the representation of the integer
156 part of the fixed point value. This can be either a real or
157 complex value, and can be either a scalar or a matrix. As the
158 fixed point representation of complex values uses separate
159 representations for the real and imaginary parts, a complex value
160 of IS gives the representation of the real and imaginary parts
161 separately. IS must contain only integer or complex integer values
162 greater than zero, and less than 30 or 62 as discussed in the
166 Similarly to IS, DS represents the number of bits in the decimal
167 part of the fixed point representation. The same conditions as for
171 This variable can be either a scalar, complex, matrix or complex
172 matrix of values that will be converted to a fixed point
173 representation. It can equally be another fixed point value, in
174 which case "fixed" has the effect of changing the representation
175 of F to another representation given by IS and DS.
177 If matrices are used for IS, DS, or F, then the dimensions of all of
178 the matrices must match. However, it is valid to have IS or DS as
179 scalar values, which will be expanded to the same dimension as the
180 other matrices, before use in the conversion to a fixed point value.
181 The variable F however, must be a matrix if either IS or DS is a matrix.
183 The most basic use of the function "fixed" can be seen in the example
185 octave:1> a = fixed(7,2,1)
190 *** local user variables:
192 prot type rows cols name
193 ==== ==== ==== ==== ====
194 rwd fixed scalar 1 1 a
196 which demonstrates the creation of a real scalar fixed point value
197 with 7 bits of precision in the integer part, 2 bits in the decimal
198 part and the value 1. The function "isfixed" can be used to identify
199 whether a variable is of the fixed point type or not. Equally, using
200 the "whos" function allows the variable to be identified as "fixed
203 Other examples of valid uses of "fixed" are
205 octave:1> a = fixed(7, 2, 1);
206 octave:2> b = fixed(7, 2+1i, 1+1i);
207 octave:3> c = fixed(7, 2, 255*rand(10,10) - 128);
208 octave:4> is = 3*ones(10,10) + 4*eye(10);
209 octave:5> d = fixed(is, 1, eye(10));
210 octave:6> e = fixed(7, 2, 255*rand(10,10)-128 +
211 > 1i*(255*rand(10,10)-128));
214 *** local user variables:
216 prot type rows cols name
217 ==== ==== ==== ==== ====
218 rwd fixed scalar 1 1 a
219 rwd fixed complex 1 1 b
220 rwd fixed matrix 10 10 c
221 rwd fixed matrix 10 10 d
222 rwd fixed complex matrix 10 10 e
224 With two arguments given to "fixed", it is assumed that F is zero or
225 a matrix of zeros, and so "fixed" called with two arguments is
226 equivalent to calling with three arguments with the third arguments
227 being zero. For example
229 octave:1> a = fixed([7,7], [2,2], zeros(1,2));
230 octave:2> b = fixed([7,7], [2,2]);
231 octave:3> assert(a == b);
233 Called with a single argument "fixed", and a fixed point argument,
234 `b = fixed(A)' is equivalent to `b = a'. If A is not itself fixed
235 point, then the integer part of A is used to create a fixed point
236 value, with the minimum number of bits needed to represent it. For
239 octave:1> b = fixed(1:4);
241 creates a fixed point row vector with 4 values. Each of these values
242 has the minimum number of bits needed to represent it. That is b(1)
243 uses 1 bit to represent the integer part, b(2:3) use 2 bits and b(4)
244 uses 3 bits. The single argument used with "fixed" can equally be a
245 complex value, in which case the real and imaginary parts are treated
246 separately to create a composite fixed point value.
249 File: fixed.info, Node: Overflow, Next: Built-in Variables, Prev: Creation, Up: Basics
251 1.4 Overflow Behavior of Fixed Point Numbers
252 ============================================
254 When converting a floating point number to a fixed point number the
255 overflow behavior of the fixed point type is such that it implements
256 clipping of the data to the maximum or minimum value that is
257 representable in the fixed point type. This effectively simulates the
258 behavior of an analog to digital conversion. For example
260 octave:1> a = fixed(7,2,200)
262 octave:2> a = fixed(7,2,-200)
265 However, the overflow behavior of the fixed point type is distinctly
266 different if the overflow occurs within a fixed point operation itself.
267 In this case the excess bits generated by the overflow are dropped.
270 octave:1> a = fixed(7,2,127) + fixed(7,2,2)
272 octave:2> a = fixed(7,2,-127) + fixed(7,2,-2)
275 The case where the representation of the fixed point object changes
276 is different again. In this case the sign is maintained, while the
277 most-significant bits of the representation are dropped. For example
279 octave:1> a = fixed(6, 2, fixed(7, 2, -127.25))
281 octave:2> a = fixed(6, 2, fixed(7, 2, 127.25))
283 octave:3> a = fixed(7, 1, fixed(7, 2, -127.25))
285 octave:4> a = fixed(7, 1, fixed(7, 2, 127.25))
288 In addition to the overflow issue discussed above, it is important to
289 take into account what happens when an operator is used on two fixed
290 point values with different representations. For example
292 octave:1> a = fixed(7,2,1);
293 octave:2> b = fixed(6,3,1);
295 octave:4> fprintf("%d integer, and %d decimal bits\n", c.int, c.dec);
296 7 integer, and 3 decimal bits
298 as can be seen the fixed point value is promoted to have an output
299 fixed point representation such that `c.int = max(a.int,b.int)' and
300 `c.dec = max(a.dec,b.dec)'. If this promotion causes the maximum number
301 of bits in a fixed point representation to be exceeded, then an error
305 File: fixed.info, Node: Built-in Variables, Next: Accessing Internal Fields, Prev: Overflow, Up: Basics
307 1.5 Fixed Point Built-in Variables
308 ==================================
310 After the fixed point type is first used, four variables are
311 initialized. These are
314 The version number of the fixed point code
316 fixed_point_warn_overflow
317 If non-zero warn of fixed point overflows. The default is 0.
319 fixed_point_count_operations
320 If non-zero count number of fixed point operations, for later
324 If non-zero keep a copy of fixed point value to allow easier
327 and they can be accessed as normal Octave built-in variables. The
328 variable `fixed_point_version' can be used to create tests in the users
329 code, to work-around any eventual problems in the fixed point type. For
332 if (strcmp(fixed_point_version, "0.6.0"))
333 a = fixed([a.int, b.int], [a.dec, b.dec],
339 although this is not a real example, since both versions of the
340 above code work with the released version of the fixed point type.
342 When optimizing the number of bits in a fixed point type, it is
343 normal to expect overflows to occur, causing errors in the calculations
344 which due to the implementation have little effect on the end result of
345 the system. However, it is sometimes useful to know exactly where
346 overflows are happening or not. A non-zero value of variable
347 `fixed_point_warn_overflow' permits the errors conditions in fixed
348 point operations to cause a warning message to be printed by octave.
349 The default behavior is to have `fixed_point_warn_overflow' be 0.
351 The octave fixed point type can keep track of all of the fixed point
352 operations and their type. This is very useful for a simple complexity
353 analysis of the algorithms. To allow the fixed point type to track
354 operations the variable `fixed_point_count_operations' must be
355 non-zero. The count of operations can then be reset with the
356 "reset_fixed_operations", and the number of operations since the last
357 reset can be given by the "display_fixed_operations" function.
359 The final in-built variable of the fixed point type is
360 `fixed_point_debug'. In normal operation this variable is of no use.
361 However setting it to a non-zero value causes a copy of the floating
362 point representation of a fixed point value to be stored internally.
363 This makes debugging code using the fixed point type significantly
367 File: fixed.info, Node: Accessing Internal Fields, Next: Function Overloading, Prev: Built-in Variables, Up: Basics
369 1.6 Accessing Internal Fields
370 =============================
372 Once a variable has been defined as a fixed point object, the
373 parameters of the field of this structure can be obtained by adding a
374 suffix to the variable. Valid suffixes are '.x', '.i', '.sign', '.int'
375 and '.dec', which return
378 The floating point representation of the fixed point number
381 The internal integer representation of the fixed point number
384 The sign of the fixed point number
387 The number of bits representing the integer part of the fixed
391 The number of bits representing the decimal part of the fixed
394 As each fixed point value in a matrix can have a different number of
395 bits in its representation, these suffixes return objects of the same
396 size as the original fixed point object. For example
398 octave:1> a = [-3:3];
399 octave:2> b = fixed(7,2,a);
415 *** local user variables:
417 prot type rows cols name
418 ==== ==== ==== ==== ====
420 rwd fixed matrix 1 7 b
423 The suffixes '.int' and '.dec' can also be used to change the
424 internal representation of a fixed point value. This can result in a
425 loss of precision in the representation of the fixed point value, which
426 models the same process as occurs in hardware. For example
428 octave:1> b = fixed(7,2,[3.25, 3.25]);
429 octave:2> b(1).dec = [0, 2];
434 However, the value itself should not be changed using the suffix
437 octave:3> b.x = [3, 3];
438 error: can not directly change the value of a fixed structure
439 error: assignment failed, or no method for `fixed matrix = matrix'
440 error: evaluating assignment expression near line 3, column 6
443 File: fixed.info, Node: Function Overloading, Next: Together, Prev: Accessing Internal Fields, Up: Basics
445 1.7 Function Overloading
446 ========================
448 An important consideration in the use of the fixed point toolbox is
449 that many of the internal functions of Octave, such as "diag", can not
450 accept fixed point objects as an input. This package therefore uses the
451 "dispatch" function of Octave-Forge to _overload_ the internal Octave
452 functions with equivalent functions that work with fixed point objects,
453 so that the standard function names can be used. However, at any time
454 the fixed point specific version of the function can be used by
455 explicitly calling its function name. The correspondence between the
456 internal function names and the fixed point versions is as follows
458 `abs' - `fabs', `atan2' - `fatan2', `ceil' - `fceil',
459 `conj' - `fconj', `cos' - `fcos', `cosh' - `fcosh',
460 `cumprod'- `fcumprod', `cumsum' - `fcumsum', `diag' - `fdiag',
461 `exp' - `fexp', `floor' - `ffloor', `imag' - `fimag',
462 `log10' - `flog10', `log' - `flog', `prod' - `fprod',
463 `real' - `freal', `reshape' - `freshape', `round' - `fround',
464 `sin' - `fsin', `sinh' - `fsinh', `sort' - `fsort',
465 `sqrt' - `fsqrt', `sum' - `fsum', `sumsq' - `fsumsq',
466 `tan' - `ftan', `tanh' - `ftanh'.
468 The version of the function that is chosen is determined by the first
469 argument of the function. So, considering the "atan2" function, if the
470 first argument is a _Matrix_, then the normal version of the function
471 is called regardless of whether the other argument of the function is a
472 fixed point objects or not.
474 Many other Octave functions work correctly with fixed point objects
475 and so overloaded versions are not necessary. This includes such
476 functions as "size" and "any".
478 It is also useful to use the '.x' option discussed in the previous
479 section, to extract a floating point representation of the fixed point
480 object for use with some functions.
483 File: fixed.info, Node: Together, Next: Precision, Prev: Function Overloading, Up: Basics
485 1.8 Putting it all Together
486 ===========================
488 Now that the basic functioning of the fixed point type has been
489 discussed, it is time to consider how to put all of it together. The
490 list of functions available for the fixed point type can be found in a
491 later section of this document (*note Function Reference::)
493 The main advantage of this fixed point type over an implementation of
494 specific fixed point code, is the ability to define a function once and
495 use as either fixed or floating point. Consider the example
497 function [b, bf] = testfixed(is,ds,n)
504 function y = myfunc(a,b)
508 In this case `b' and `bf' will be returned from the function
509 "testfixed" as floating and fixed point types respectively, while the
510 underlying function "myfunc" does not explicitly define that it uses a
511 fixed point type. This is a major advantage, as it is critical to
512 understand the loss of precision in an algorithm when converting from
513 floating to fixed point types for an optimal hardware implementation.
514 This mixing of functions that treat both floating and fixed point types
515 can even apply to Oct-files (*note Oct-files::).
517 The main limitation to the above is the use of the concatenation
518 operator, such as `[a,b]', that is hard-coded in versions of Octave
519 prior to 2.1.58 and is thus not aware of the fixed-point type.
520 Therefore, such code should be avoided in earlier versions of Octave
521 and the function "concat" supplied with this package used instead.
524 File: fixed.info, Node: Precision, Next: Lookup Tables, Prev: Together, Up: Basics
526 1.9 Problems of Precision in Calculations
527 =========================================
529 When dimensioning the fixed point variables, care must be taken so that
530 all intermediate operations don't cause a loss in the precision. This
531 can occur with any operator or function that takes a large argument and
532 gives a small result. Minor variations in the initial argument can
533 result in large changes in the final result.
535 For instance, consider the "log" operator, in the example
537 octave:1> a = fixed(7,2,5.25);
538 octave:2> b = exp(log(a))
541 The logarithm `log(a)' is 1.65, which is rounded to 1.5. The
542 exponential `exp(log(a))' is then 4.48 which is rounded to 4.25.
544 A particular case in point is the power operator for complex number,
545 which is implemented by the standard C++ class as
547 X ^ Y = exp ( Y * log(X) )
549 Unless a large decimal precision is specified for this operator, the
550 results will be wildly different than expected. For example
552 octave:1> fixed(7,2,4*1i) ^ fixed(7,2,1)
554 octave:2> fixed(7,5,4*1i) ^ fixed(7,5,1)
555 ans = 0.000000 + 3.812500i
557 If the user chooses to use certain functions and operators, it is
558 their responsibility to understand the implementation of the these
559 operators, as used by their compilers to ensure the desired behavior.
560 Alternatively, the user is recommended to implement certain operations
561 as lookup tables, rather than use the built-in operator or function.
562 This is how such general functions are implemented in hardware and so
563 this is not a significant problem.
566 File: fixed.info, Node: Lookup Tables, Next: Known Problems, Prev: Precision, Up: Basics
571 It is common to implement complex functions in hardware by an equivalent
572 lookup table. This has the advantage of speed, saving on the complexity
573 of a full implementation of certain functions, and avoiding rounding
574 errors if the complex function is implemented as a combination of
575 sub-functions. The disadvantage is that the lookup requires the use of
576 a read-only memory in hardware. Due to size limitations on this memory
577 it might not be possible to represent all possible values of a function.
579 This section discusses the use of lookup tables with the fixed point
580 type. It is assumed that the function "lookup" of Octave-forge is
581 installed. The easiest way to explain the use of a fixed point lookup
582 table is to discuss an example. Consider a fixed point value in the
583 range `-pi:pi', and we wish to represent the sine function in this
584 range. The creation of the lookup table can then be performed as
587 octave:1> is = 2; ds = 6;
588 octave:2> x = [-3.125:0.125:3.125]; % 3.125 ~ pi
589 octave:3> y = sin(x);
590 octave:4> table_float = create_lookup_table(x, y);
591 octave:5> table_fixed = create_lookup_table(fixed(is,ds,x),
594 A real implementation of this function in hardware might use to the
595 symmetry of the sine function to only require the lookup table for
596 `[0:pi/2]' to be stored. However, for simulation there is little reason
597 to introduce this complication.
599 To evaluate the value of the function use the lookup table created by
600 "create_lookup_table", the function "lookup_table" is then used. This
601 function can either be used to give the closest evalued value below the
602 desired value, or it can be used to interpolate the table as might be
603 done in hardware. For example
605 octave:6> x0 = [-pi:0.01:pi];
606 octave:7> y0 = sin(x);
607 octave:8> y1 = lookup_table(table_float, x0, "linear");
608 octave:9> y2 = lookup_table(table_fixed, fixed(is,ds,x0), "linear");
611 File: fixed.info, Node: Known Problems, Prev: Lookup Tables, Up: Basics
616 Before reporting a bug compare it to this list of known problems
619 For versions of Octave prior to 2.1.58, the concatenation of fixed
620 point objects returns a Matrix type. That is `[fixed(7,2,[1, 2]),
621 fixed(7,2,3)]' returns a matrix when it should return another
622 fixed point matrix. This problem is due to the implementation of
623 matrix concatenation in earlier versions of Octave being
624 hard-coded for the basic types it knows rather than being
627 The workaround is to explicitly convert the returned value back to
628 the correct fixed point object. For instance
630 octave:1> a = fixed(7,2,[1,2]);
631 octave:2> b = fixed(7,2,3);
632 octave:3> c = fixed([a.int, b.int], [a.dec, b.dec],
635 Alternatively, use the supplied function "concat" that explicitly
636 performs the above above, but can also be used for normal matrices.
638 Since Octave version 2.1.58, `[fixed(7,2,[1,2]),fixed(7,2,3)]'
639 returns another fixed point object as expected.
641 Saving fixed point objects
642 Saving of fixed point variables is only implemented in versions of
643 Octave later than 2.1.53. If you are using a recent version of
644 Octave then saving a fixed point variable is as simple as
646 octave:2> save a.mat a
648 where A is a fixed point variable. To reload the variable within
649 octave, the fixed point types must be installed prior to a call to
652 octave:1> dummy = fixed(1,1);
655 With versions of octave later than 2.1.53, fixed point variables
656 can be saved in the octave binary and ascii formats, as well as
657 the HDF5 format. If you are using an earlier version of octave,
658 you can not directly save a fixed point variable. You can however
659 save the information it contains and reconstruct the data
660 afterwards by doing something like
662 octave:2> x = a.x; is = a.int; ds = a.dec;
663 octave:3> save a.mat x is ds;
665 where A is a fixed point object.
667 Some functions and operators return very poor results
668 Please read the previous section. Also if the problem manifests
669 when using complex arguments, try to understand your compilers
670 constructor of complex operators and functions from the base fixed
671 point operators and functions. The relevant file for the gcc 3.x
672 versions of the compiler can be found in
673 `/usr/include/g++-v3/bits/std_complex.h'.
675 Function "foo" returns fixed point types while "bar"
676 does not? If the existing functions, written as m-files, respect
677 the use (or rather non-use) of the concatentaion operator, then
678 these functions will operate correctly. However, many functions
679 don't and thus will return a floating type for a fixed point
680 input, when run on versions of Octave earlier than 2.1.58. All
681 functions should be checked by the user for their correct
682 operation before using them.
684 Additionally, existing oct-files will not operate correctly with
685 fixed point inputs, as they are not aware of the fixed point type
686 and will just extract the floating point value to operate on.
688 A third class of function are the inbuilt functions like "any",
689 "size", etc. As the fixed point type includes the underlying
690 functions for these to work correctly, they give the correct
691 result even though there is no corresponding fixed point specific
692 version of these functions.
694 Why is my code so slow when using fixed point
695 This is due to several reasons, firstly the normal functions in
696 octave use optimized libraries to accelerate their operation. This
697 is not possible when using fixed point.
699 Also there is no fixed point type native to the machines Octave
700 runs on. This naturally makes the fixed point type slow, due to
701 the fact that the fixed point operators check for overflows, etc
702 at all steps in the operation and act accordingly. This is
703 particularly true in the case of matrix multiplication where each
704 multiplication and addition can be subject to overflows. Thus
706 octave:1> x = randn(100,100);
707 octave:2> y0 = fixed(7,6,x*x);
708 octave:3> y1 = fixed(7,6,x)*fixed(7,6,x);
710 does not give equivalent operations for Y0 and Y1. With all this
711 additionally checking, you can not expect your code to run as fast
712 when using the fixed point type.
714 When running under cygwin I get a dlopen error.
715 The build under cygwin is slightly different, in that most of the
716 fixed point functions are compiled as a shared library that is
717 linked to the main oct-file. This is to allow other oct-files to
718 use the fixed-point type which is not possible under cygwin
719 otherwise, since compilation under cygwin requires that all
720 symbols are resolved at compile time.
722 If the shared libraries are not installed somewhere that can be
723 found when running octave, then you will get an error like
725 octave:1> a = fixed(7,2,1)
726 error: dlopen: Win32 error 126
727 error: `fixed' undefined near line 1 column 5
728 error: evaluating assignment expression near line 1, column 3
730 There are two files `liboctave_fixed.dll' and `liboctave_fixed.dll.a'
731 that must be installed. Typically, these should be installed in the same
732 directory that you can `liboctave.dll' and `liboctave.dll.a'
733 respectively. If you use the same `--prefix' option to configure both
734 octave and octave-forge then this should happen automatically.
737 File: fixed.info, Node: Programming, Next: Example, Prev: Basics, Up: Top
739 2 Using the fixed-point type in C++ and oct-files
740 *************************************************
742 Octave supplies a matrix template library to create matrix and vector
743 objects from basic types. All of the properties of these Octave classes
744 will not be described here. However the base classes and the
745 particularly of the classes created using the Octave matrix templates
748 There are two basic fixed point types: `FixedPoint' and
749 `FixedPointComplex' representing the fixed point representation of real
750 and complex numbers respectively. The Octave matrix templates are used
751 to created the classes `FixedMatrix', `FixedRowVector' and
752 `FixedColumnVector' from the base class `FixedPoint'. Similar the
753 complex fixed point types `FixedComplexMatrix', `FixedComplexRowVector'
754 and `FixedComplexColumnVectors' are constructed from the base class
757 This section discusses the definitions of the base classes, their
758 extension with the Octave matrix templates, the upper level Octave
759 classes and the use of all of these when writing oct-files.
763 * FixedPoint:: The `FixedPoint' base class
764 * FixedPointComplex:: The `FixedPointComplex' base class
765 * Derived:: The derived classes using the Octave template classes
766 * Upper:: The upper level Octave classes
767 * Oct-files:: Writing oct-files with the fixed point type
770 File: fixed.info, Node: FixedPoint, Next: FixedPointComplex, Prev: Programming, Up: Programming
772 2.1 The `FixedPoint' Base Class
773 ===============================
777 * FPConstructors:: `FixedPoint' constructors
778 * FPSpecific:: `FixedPoint' specific methods
779 * FPOperators:: `FixedPoint' operators
780 * FPFunctions:: `FixedPoint' functions
783 File: fixed.info, Node: FPConstructors, Next: FPSpecific, Prev: FixedPoint, Up: FixedPoint
785 2.1.1 `FixedPoint' Constructors
786 -------------------------------
788 `FixedPoint::FixedPoint ()'
789 Create a fixed point object with only a sign bit
791 `FixedPoint::FixedPoint (unsigned int is, unsigned int ds)'
792 Create a fixed point object with `is' bits for the integer part and
793 `ds' bits for the decimal part. The fixed point object will be
794 initialized to be zero
796 `FixedPoint::FixedPoint (unsigned int is, unsigned int ds, FixedPoint &x)'
797 Create a fixed point object with `is' bits for the integer part and
798 `ds' bits for the decimal part, loaded with the fixed point value
799 `x'. If `is + ds' is greater than `sizeof(int)*8 - 2', the error
802 `FixedPoint::FixedPoint (unsigned int is, unsigned int ds, const double x)'
803 Create a fixed point object with `is' bits for the integer part and
804 `ds' bits for the decimal part, loaded with the value `x'. If `is
805 + ds' is greater than `sizeof(int)*8 - 2', the error handler is
808 `FixedPoint::FixedPoint (unsigned int is, unsigned int ds, unsigned int i, unsigned int d)'
809 Create a fixed point object with `is' bits for the integer part and
810 `ds' bits for the decimal part, loading the integer part with `i'
811 and the decimal part with `d'. It should be noted that `i' and `d'
812 are both unsigned and are the strict representation of the bits of
813 the fixed point value.
815 `FixedPoint::FixedPoint (const int x)'
816 Create a fixed point object with the minimum number of bits for
817 the integer part `is' needed to represent `x'. If `is' is greater
818 than `sizeof(int)*8 - 2', the error handler is called.
820 `FixedPoint::FixedPoint (const double x)'
821 Create a fixed point object with the minimum number of bits for
822 the integer part `is' needed to represent the integer part of `x'.
823 If `is' is greater than `sizeof(int)*8 - 2', the error handler is
826 `FixedPoint::FixedPoint (const FixedPoint &x)'
827 Create a copy of the fixed point object `x'
830 File: fixed.info, Node: FPSpecific, Next: FPOperators, Prev: FPConstructors, Up: FixedPoint
832 2.1.2 `FixedPoint' Specific Methods
833 -----------------------------------
835 `double FixedPoint::fixedpoint()'
836 Method to create a `double' from the current fixed point object
838 `double fixedpoint (const FixedPoint &x)'
839 Create a `double' from the fixed point object `x'
841 `int FixedPoint::sign ()'
842 Return `-1' for negative numbers, `1' for positive and `0' if the
843 current fixed point object is zero.
845 `int sign (FixedPoint &x)'
846 Return `-1' for negative numbers, `1' for positive and `0' if the
847 fixed point object `x' is zero.
849 `char FixedPoint::signbit ()'
850 Return the sign bit of the current fixed point number (`0' for
851 positive number, `1' for negative number).
853 `char signbit (FixedPoint &x)'
854 Return the sign bit of the fixed point number `x' (`0' for positive
855 number, `1' for negative number).
857 `int FixedPoint::getintsize ()'
858 Return the number of bit `is' used to represent the integer part
859 of the current fixed point object.
861 `int getintsize (FixedPoint &x)'
862 Return the number of bit `is' used to represent the integer part
863 of the fixed point object `x'.
865 `int FixedPoint::getdecsize ()'
866 Return the number of bit `ds' used to represent the decimal part
867 of the current fixed point object.
869 `int getdecsize (FixedPoint &x)'
870 Return the number of bit `ds' used to represent the decimal part
871 of the fixed point object `x'.
873 `unsigned int FixedPoint::getnumber ()'
874 Return the integer representation of the fixed point value of the
875 current fixed point object.
877 `unsigned int getnumber (FixedPoint &x)'
878 Return the integer representation of the fixed point value of the
879 fixed point object `x'.
881 `FixedPoint FixedPoint::chintsize (const int n)'
882 Return a fixed point object equivalent to the current fixed point
883 number but with the number of bits representing the integer part
884 `is' changed to `n'. If the result of this operation causes `is +
885 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
888 `FixedPoint FixedPoint::chdecsize (const int n)'
889 Return a fixed point object equivalent to the current fixed point
890 number but with the number of bits representing the decimal part
891 `ds' changed to `n'. If the result of this operation causes `is +
892 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
895 `FixedPoint FixedPoint::incintsize (const int n)'
896 Return a fixed point object equivalent to the current fixed point
897 number but with the number of bits representing the integer part
898 `is' increased by `n'. If `n' is negative, then `is' is decreased.
899 If the result of this operation causes `is + ds' to be greater than
900 `sizeof(int)*8 - 2', the error handler is called.
902 `FixedPoint FixedPoint::incintsize ()'
903 Return a fixed point object equivalent to the current fixed point
904 number but with the number of bits representing the integer part
905 `is' increased by 1. If the result of this operation causes `is +
906 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
909 `FixedPoint FixedPoint::incdecsize (const int n)'
910 Return a fixed point object equivalent to the current fixed point
911 number but with the number of bits representing the decimal part
912 `ds' increased by `n'. If `n' is negative, then `ds' is decreased.
913 If the result of this operation causes `is + ds' to be greater than
914 `sizeof(int)*8 - 2', the error handler is called.
916 `FixedPoint FixedPoint::incdecsize ()'
917 Return a fixed point object equivalent to the current fixed point
918 number but with the number of bits representing the decimal part
919 `ds' increased by 1. If the result of this operation causes `is +
920 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
924 File: fixed.info, Node: FPOperators, Next: FPFunctions, Prev: FPSpecific, Up: FixedPoint
926 2.1.3 `FixedPoint' Operators
927 ----------------------------
929 `FixedPoint operator +'
930 Unary `+' of a fixed point object
932 `FixedPoint operator -'
933 Unary `-' of a fixed point object
935 `FixedPoint operator !'
936 Unary `!' operator of the fixedpoint object, with the the sign bit.
937 This is not the same operator as `-' and is not the same operator
938 as the octave `!' operator.
940 `FixedPoint operator ++'
941 Unary increment operator (pre and postfix). Uses the smallest
942 representable value to increment (ie `2 ^ (- ds)' )
944 `FixedPoint operator --'
945 Unary decrement operator (pre and postfix). Uses the smallest
946 representable value to decrement (ie `2 ^ (- ds)' )
948 `FixedPoint operator = (const FixedPoint &x)'
949 Assignment operators. Copies fixed point object `x'
951 `FixedPoint operator += (const FixedPoint &x)'
952 `FixedPoint operator -= (const FixedPoint &x)'
953 `FixedPoint operator *= (const FixedPoint &x)'
954 `FixedPoint operator /= (const FixedPoint &x)'
955 Assignment operators, working on both the input and output
956 objects. The output object's fixed point representation is
957 promoted such that the largest values of `is' and `ds' are taken
958 from the input and output objects. If the result of this operation
959 causes `is + ds' to be greater than `sizeof(int)*8 - 2', the error
962 `FixedPoint operator <<= (const int s)'
963 `FixedPoint operator << (const FixedPoint &x, const int s)'
964 Perform a left-shift of a fixed point object. This is equivalent
965 to a multiplication by a power of 2. The sign-bit is preserved.
966 This differs from the `rshift' function discussed below in the
967 `is' and `ds' are unchanged.
969 `FixedPoint operator >>= (const int s)'
970 `FixedPoint operator >> (const FixedPoint &x, const int s)'
971 Perform a right-shift of the fixed point object. This is
972 equivalent to a division by a power of 2. Note that the sign-bit
973 is preserved. This differs from the `rshift' function discussed
974 below in the `is' and `ds' are unchanged.
976 `FixedPoint operator + (const FixedPoint &x, const FixedPoint &y)'
977 `FixedPoint operator - (const FixedPoint &x, const FixedPoint &y)'
978 `FixedPoint operator * (const FixedPoint &x, const FixedPoint &y)'
979 `FixedPoint operator / (const FixedPoint &x, const FixedPoint &y)'
980 Two argument operators. The output objects fixed point
981 representation is promoted such that the largest values of `is'
982 and `ds' are taken from the two arguments. If the result of this
983 operation causes `is + ds' to be greater than `sizeof(int)*8 -
984 2', the error handler is called.
986 `bool operator == (const FixedPoint &x, const FixedPoint &y)'
987 `bool operator != (const FixedPoint &x, const FixedPoint &y)'
988 `bool operator < (const FixedPoint &x, const FixedPoint &y)'
989 `bool operator <= (const FixedPoint &x, const FixedPoint &y)'
990 `bool operator > (const FixedPoint &x, const FixedPoint &y)'
991 `bool operator >= (const FixedPoint &x, const FixedPoint &y)'
992 Fixed point comparison operators. The fixed point object `x' and
993 `y' can have different representations (values of `is' and `ds').
995 `std::istream &operator >> (std::istream &s, FixedPoint &x)'
996 Read a fixed point object from `s' stream and store it into `x'
997 keeping the fixed point representation in `x'. If the value read is
998 not a fixed point object, the error handler is invoked.
1000 `std::ostream &operator << (std::ostream &s, const FixedPoint &x)'
1001 Send into the stream `s', a formatted fixed point value `x'
1004 File: fixed.info, Node: FPFunctions, Prev: FPOperators, Up: FixedPoint
1006 2.1.4 `FixedPoint' Functions
1007 ----------------------------
1009 `FixedPoint rshift (const FixedPoint &x, int s)'
1010 Do a right shift of `s' bits of a fixed precision number
1011 (equivalent to a division by a power of 2). The representation of
1012 the fixed point object is adjusted to suit the new fixed point
1013 object (i.e. `ds++' and `is = is == 0 ? 0 : is-1')
1015 `FixedPoint lshift (const FixedPoint &x, int s)'
1016 Do a left shift of `s' bits of a fixed precision number (equivalent
1017 to a multiplication by a power of 2). The representation of the
1018 fixed point object is adjusted to suit the new fixed point object
1019 (i.e. `is++' and `ds = ds == 0 ? 0 : ds-1')
1021 `FixedPoint abs (const FixedPoint &x)'
1022 Returns the modulus of `x'
1024 `FixedPoint cos (const FixedPoint &x)'
1025 Returns the cosine of `x'
1027 `FixedPoint cosh (const FixedPoint &x)'
1028 Returns the hyperbolic cosine of `x'
1030 `FixedPoint sin (const FixedPoint &x)'
1031 Returns the sine of `x'
1033 `FixedPoint sinh (const FixedPoint &x)'
1034 Returns the hyperbolic sine of `x'
1036 `FixedPoint tan (const FixedPoint &x)'
1037 Returns the tangent of `x'
1039 `FixedPoint tanh (const FixedPoint &x)'
1040 Returns the hyperbolic tangent of `x'
1042 `FixedPoint sqrt (const FixedPoint &x)'
1043 Returns the square root of `x'
1045 `FixedPoint pow (const FixedPoint &x, int y)'
1046 `FixedPoint pow (const FixedPoint &x, double y)'
1047 `FixedPoint pow (const FixedPoint &x, const FixedPoint &y)'
1048 Returns the `x' raised to the power `y'
1050 `FixedPoint exp (const FixedPoint &x)'
1051 Returns the exponential of `x'
1053 `FixedPoint log (const FixedPoint &x)'
1054 Returns the logarithm of `x'
1056 `FixedPoint log10 (const FixedPoint &x)'
1057 Returns the base 10 logarithm of `x'
1059 `FixedPoint atan2 (const FixedPoint &y, const FixedPoint &x)'
1060 Returns the arc tangent of `x' and `y'
1062 `FixedPoint floor (const FixedPoint &x)'
1063 Returns the rounded value of `x' downwards to the nearest integer
1065 `FixedPoint ceil (const FixedPoint &x)'
1066 Returns the rounded value of `x' upwards to the nearest integer
1068 `FixedPoint rint (const FixedPoint &x)'
1069 Returns the rounded value of `x' to the nearest integer
1071 `FixedPoint round (const FixedPoint &x)'
1072 Returns the rounded value of `x' to the nearest integer. The
1073 difference with `rint' is that `0.5' is rounded to `1' and not `0'.
1074 This conforms to the behavior of the octave `round' function.
1076 `std::string getbitstring (const FixedPoint &x)'
1077 Return a string containing the bits of `x'
1080 File: fixed.info, Node: FixedPointComplex, Next: Derived, Prev: FixedPoint, Up: Programming
1082 2.2 The `FixedPointComplex' Base Class
1083 ======================================
1085 The `FixedPointComplex' class is derived using the C++ compilers
1086 inbuilt `complex' class and is instantiated as
1087 `std::complex<FixedPoint>'. Therefore the exact behavior of the complex
1088 fixed point type is determined by the complex class used by the C++
1089 compiler. The user is advised to understand their C++ compilers
1090 implementation of the complex functions that they use, and particularly
1091 the effects that they will have on the precision of fixed point
1096 * FPCConstructors:: `FixedPointComplex' constructors
1097 * FPCSpecific:: `FixedPointComplex' specific methods
1098 * FPCOperators:: `FixedPointComplex' operators
1099 * FPCFunctions:: `FixedPointComplex' functions
1102 File: fixed.info, Node: FPCConstructors, Next: FPCSpecific, Prev: FixedPointComplex, Up: FixedPointComplex
1104 2.2.1 `FixedPointComplex' Constructors
1105 --------------------------------------
1107 `FixedPointComplex::FixedPointComplex ()'
1108 Create a complex fixed point object with only a sign bit
1110 `FixedPointComplex::FixedPointComplex (unsigned int is, unsigned int ds)'
1111 Create a complex fixed point object with `is' bits for the integer
1112 part and `ds' bits for the decimal part. The fixed point object
1113 will be initialized to zero.
1115 `FixedPointComplex::FixedPointComplex (unsigned int is, unsigned int ds, FixedPoint &x)'
1116 Create a complex fixed point object with `is' bits for the integer
1117 part and `ds' bits for the decimal part of both real and imaginary
1118 parts, loaded with the fixed point value `x' in the real part and
1119 zero in the imaginary. If `is + ds' is greater than `sizeof(int)*8
1120 - 2', the error handler is called.
1122 `FixedPointComplex::FixedPointComplex (unsigned int is, unsigned int ds, FixedPoint &r, FixedPoint &i)'
1123 Create a complex fixed point object with `is' bits for the integer
1124 part and `ds' bits for the decimal part of both real and imaginary
1125 parts, loaded with the fixed point value `r' in the real part and
1126 `i' the imaginary part. If `is + ds' is greater than
1127 `sizeof(int)*8 - 2', the error handler is called.
1129 `FixedPointComplex::FixedPointComplex (unsigned int is, unsigned int ds, FixedPointComplex &x)'
1130 Create a complex fixed point object with `is' bits for the integer
1131 part and `ds' bits for the decimal part of both real and imaginary
1132 parts, loaded with the complex fixed point value `x'. If `is + ds'
1133 is greater than `sizeof(int)*8 - 2', the error handler is called.
1135 `FixedPointComplex::FixedPointComplex (unsigned int is, unsigned int ds, const double x)'
1136 Create a complex fixed point object with `is' bits for the integer
1137 part and `ds' bits for the decimal part of both real and imaginary
1138 parts, loaded with the fixed point value `x' in the real part and
1139 zero in the imaginary. If `is + ds' is greater than `sizeof(int)*8
1140 - 2', the error handler is called.
1142 `FixedPointComplex::FixedPointComplex (unsigned int is, unsigned int ds, const double r, const double i)'
1143 Create a complex fixed point object with `is' bits for the integer
1144 part and `ds' bits for the decimal part of both real and imaginary
1145 parts, loaded with the fixed point value `r' in the real part and
1146 `i' in the imaginary part. If `is + ds' is greater than
1147 `sizeof(int)*8 - 2', the error handler is called.
1149 `FixedPointComplex::FixedPointComplex (unsigned int is, unsigned int ds, const Complex c)'
1150 Create a complex fixed point object with `is' bits for the integer
1151 part and `ds' bits for the decimal part of both real and imaginary
1152 parts, loaded with the fixed point value `c' in the real and
1153 imaginary parts. If `is + ds' is greater than `sizeof(int)*8 -
1154 2', the error handler is called.
1156 `FixedPointComplex::FixedPointComplex (unsigned int is, unsigned int ds, const Complex a, const Complex b)'
1157 Create a complex fixed point object with `is' bits for the integer
1158 part and `ds' bits for the decimal part of both real and imaginary
1159 parts, loaded with the fixed point value `a' in the integer parts
1160 of the of the value and `b' in the decimal part. It should be
1161 noted that `a' and `b' are both unsigned and are the strict
1162 representation of the bits of the fixed point value and considered
1163 as integers. If `is + ds' is greater than `sizeof(int)*8 - 2', the
1164 error handler is called.
1166 `FixedPointComplex::FixedPointComplex (const Complex& is, const Complex& ds)'
1167 Create a complex fixed point object with `is' bits for the integer
1168 part and `ds' bits for the decimal part of both real and imaginary
1169 parts, loaded with zero in the real and imaginary parts. The real
1170 part of `is' is used for the real part of the complex fixed point
1171 object, while the imaginary part of `is' is used for the imaginary
1172 part. If either the sum of the real or imaginary parts of `is +
1173 ds' is greater than `sizeof(int)*8 - 2', the error handler is
1176 `FixedPointComplex::FixedPointComplex (const Complex& is, const Complex& ds, const Complex& c)'
1177 Create a complex fixed point object with `is' bits for the integer
1178 part and `ds' bits for the decimal part of both real and imaginary
1179 parts, loaded with the complex fixed point value `c' in the real
1180 and imaginary parts. The real part of `is' is used for the real
1181 part of the complex fixed point object, while the imaginary part
1182 of `is' is used for the imaginary part. If either the sum of the
1183 real or imaginary parts of `is + ds' is greater than
1184 `sizeof(int)*8 - 2', the error handler is called.
1186 `FixedPointComplex::FixedPointComplex (const Complex& is, const Complex& ds, const FixedPointComplex& c)'
1187 Create a complex fixed point object with `is' bits for the integer
1188 part and `ds' bits for the decimal part of both real and imaginary
1189 parts, loaded with the complex fixed point value `c' in the real
1190 and imaginary parts. The real part of `is' is used for the real
1191 part of the complex fixed point object, while the imaginary part
1192 of `is' is used for the imaginary part. If either the sum of the
1193 real or imaginary parts of `is + ds' is greater than
1194 `sizeof(int)*8 - 2', the error handler is called.
1196 `FixedPointComplex::FixedPointComplex (const Complex& is, const Complex& ds, const Complex& a, const Complex& b)'
1197 Create a complex fixed point object with `is' bits for the integer
1198 part and `ds' bits for the decimal part of both real and imaginary
1199 parts, loaded with the fixed point value `a' in the integer parts
1200 of the of the value and `b' in the decimal part. It should be
1201 noted that `a' and `b' are both unsigned and are the strict
1202 representation of the bits of the fixed point value and considered
1203 as integers. If either the sum of the real or imaginary parts of
1204 `is + ds' is greater than `sizeof(int)*8 - 2', the error handler
1207 `FixedPointComplex::FixedPointComplex (const std::complex<FixedPoint> &c)'
1208 Create a complex fixed point object with the minimum number of
1209 bits for the integer part `is' needed to represent the real and
1210 imaginary integer parts of `x'. If `is' is greater than
1211 `sizeof(int)*8 - 2', the error handler is called. The real and
1212 imaginary parts are treated separately.
1214 `FixedPointComplex::FixedPointComplex (const FixedPointComplex &x)'
1215 Create a copy of the complex fixed point object `x'
1217 `FixedPointComplex::FixedPointComplex (const FixedPoint &x)'
1218 Create a copy of the fixed point object `x', into a complex fixed
1219 point object leaving the imaginary part at zero.
1221 `FixedPointComplex::FixedPointComplex (const FixedPoint &r, const FixedPoint &i)'
1222 Create a copy of the fixed point objects `r' and `i', into a the
1223 real and imaginary parts of a complex fixed point object
1226 `FixedPointComplex::FixedPointComplex (const int x)'
1227 Create a fixed point object with the minimum number of bits for
1228 the integer part `is' needed to represent `x'. If `is' is greater
1229 than `sizeof(int)*8 - 2', the error handler is called.
1231 `FixedPointComplex::FixedPointComplex (const double x)'
1232 Create a fixed point object with the minimum number of bits for
1233 the integer part `is' needed to represent the integer part of `x'.
1234 If `is' is greater than `sizeof(int)*8 - 2', the error handler is
1237 `FixedPointComplex (const Complex& is, const Complex& ds, const double& d)'
1238 Create a complex fixed point object with `is' bits for the integer
1239 part and `ds' bits for the decimal part of both real and imaginary
1240 parts, loaded with the double value `d' in the real and zero in
1241 the imaginary parts. The real part of `is' is used for the real
1242 part of the complex fixed point object, while the imaginary part
1243 of `is' is used for the imaginary part. If either the sum of the
1244 real or imaginary parts of `is + ds' is greater than
1245 `sizeof(int)*8 - 2', the error handler is called.
1248 File: fixed.info, Node: FPCSpecific, Next: FPCOperators, Prev: FPCConstructors, Up: FixedPointComplex
1250 2.2.2 `FixedPointComplex' Specific Methods
1251 ------------------------------------------
1253 `Complex FixedPointComplex::fixedpoint()'
1254 Method to create a `Complex' from the current fixed point object
1256 `Complex fixedpoint (const FixedPointComplex &x)'
1257 Create a `Complex' from the fixed point object `x'
1259 `Complex FixedPointComplex::sign ()'
1260 Return `-1' for negative numbers, `1' for positive and `0' if the
1261 current fixed point object is zero. Real and imaginary parts
1262 treated separately and returned in the real and imaginary parts of
1265 `Complex sign (FixedPointComplex &x)'
1266 Return `-1' for negative numbers, `1' for positive and `0' if the
1267 fixed point object `x' is zero. Real and imaginary parts treated
1268 separately and returned in the real and imaginary parts of the
1271 `Complex FixedPointComplex::getintsize ()'
1272 Return the number of bit `is' used to represent the integer part
1273 of the current fixed point object. Real and imaginary parts
1274 treated separately and returned in the real and imaginary parts of
1277 `Complex getintsize (FixedPointComplex &x)'
1278 Return the number of bit `is' used to represent the integer part
1279 of the fixed point object `x'. Real and imaginary parts treated
1280 separately and returned in the real and imaginary parts of the
1283 `Complex FixedPointComplex::getdecsize ()'
1284 Return the number of bit `ds' used to represent the decimal part
1285 of the current fixed point object. Real and imaginary parts
1286 treated separately and returned in the real and imaginary parts of
1289 `Complex getdecsize (FixedPointComplex &x)'
1290 Return the number of bit `ds' used to represent the decimal part
1291 of the fixed point object `x'. Real and imaginary parts treated
1292 separately and returned in the real and imaginary parts of the
1295 `Complex FixedPointComplex::getnumber ()'
1296 Return the integer representation of the fixed point value of the
1297 current fixed point object. Real and imaginary parts treated
1298 separately and returned in the real and imaginary parts of the
1301 `Complex getnumber (FixedPointComplex &x)'
1302 Return the integer representation of the fixed point value of the
1303 fixed point object `x'. Real and imaginary parts treated
1304 separately and returned in the real and imaginary parts of the
1307 `FixedPointComplex FixedPointComplex::chintsize (const Complex n)'
1308 Return a fixed point object equivalent to the current fixed point
1309 number but with the number of bits representing the integer part
1310 `is' changed to `n'. If the result of this operation causes `is +
1311 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1312 called. Real and imaginary parts treated separately and returned
1313 in the real and imaginary parts of the return object.
1315 `FixedPointComplex FixedPointComplex::chdecsize (const Complex n)'
1316 Return a fixed point object equivalent to the current fixed point
1317 number but with the number of bits representing the decimal part
1318 `ds' changed to `n'. If the result of this operation causes `is +
1319 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1320 called. Real and imaginary parts treated separately and returned
1321 in the real and imaginary parts of the return object.
1323 `FixedPointComplex FixedPointComplex::incintsize (const Complex n)'
1324 Return a fixed point object equivalent to the current fixed point
1325 number but with the number of bits representing the integer part
1326 `is' increased by `n'. If `n' is negative, then `is' is decreased.
1327 If the result of this operation causes `is + ds' to be greater than
1328 `sizeof(int)*8 - 2', the error handler is called. Real and
1329 imaginary parts treated separately and returned in the real and
1330 imaginary parts of the return object.
1332 `FixedPointComplex FixedPointComplex::incintsize ()'
1333 Return a fixed point object equivalent to the current fixed point
1334 number but with the number of bits representing the integer part
1335 `is' increased by 1. If the result of this operation causes `is +
1336 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1337 called. Real and imaginary parts treated separately and returned
1338 in the real and imaginary parts of the return object.
1340 `FixedPointComplex FixedPointComplex::incdecsize (const Complex n)'
1341 Return a fixed point object equivalent to the current fixed point
1342 number but with the number of bits representing the decimal part
1343 `ds' increased by `n'. If `n' is negative, then `ds' is decreased.
1344 If the result of this operation causes `is + ds' to be greater than
1345 `sizeof(int)*8 - 2', the error handler is called. Real and
1346 imaginary parts treated separately and returned in the real and
1347 imaginary parts of the return object.
1349 `FixedPointComplex FixedPointComplex::incdecsize ()'
1350 Return a fixed point object equivalent to the current fixed point
1351 number but with the number of bits representing the decimal part
1352 `ds' increased by 1. If the result of this operation causes `is +
1353 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1354 called. Real and imaginary parts treated separately and returned
1355 in the real and imaginary parts of the return object.
1358 File: fixed.info, Node: FPCOperators, Next: FPCFunctions, Prev: FPCSpecific, Up: FixedPointComplex
1360 2.2.3 `FixedPointComplex' Operators
1361 -----------------------------------
1363 `FixedPointComplex operator +'
1364 Unary `+' of a complex fixed point object
1366 `FixedPointComplex operator -'
1367 Unary `-' of a complex fixed point object
1369 `FixedPointComplex operator = (const FixedPointComplex &x)'
1370 Assignment operators. Copies complex fixed point object `x'
1372 `FixedPointComplex operator += (const FixedPointComplex &x)'
1373 `FixedPointComplex operator -= (const FixedPointComplex &x)'
1374 `FixedPointComplex operator *= (const FixedPointComplex &x)'
1375 `FixedPointComplex operator /= (const FixedPointComplex &x)'
1376 Assignment operators, working on both the input and output
1377 objects. The output object's fixed point representation is
1378 promoted such that the largest values of `is' and `ds' are taken
1379 from the input and output objects. If the result of this operation
1380 causes `is + ds' to be greater than `sizeof(int)*8 - 2', the error
1383 `FixedPointComplex operator + (const FixedPointComplex &x, const FixedPointComplex &y)'
1384 `FixedPointComplex operator - (const FixedPointComplex &x, const FixedPointComplex &y)'
1385 `FixedPointComplex operator * (const FixedPointComplex &x, const FixedPointComplex &y)'
1386 `FixedPointComplex operator / (const FixedPointComplex &x, const FixedPointComplex &y)'
1387 Two argument operators. The output objects complex fixed point
1388 representation is promoted such that the largest values of `is'
1389 and `ds' are taken from the two arguments. If the result of this
1390 operation causes `is + ds' to be greater than `sizeof(int)*8 -
1391 2', the error handler is called.
1393 `bool operator == (const FixedPointComplex &x, const FixedPointComplex &y)'
1394 `bool operator != (const FixedPointComplex &x, const FixedPointComplex &y)'
1395 Complex fixed point comparison operators. The complex fixed point
1396 object `x' and `y' can have different representations (values of
1399 `std::istream &operator >> (std::istream &s, FixedPointComplex &x)'
1400 Read a fixed point object from `s' stream and store it into `x'
1401 keeping the fixed point representation in `x'. If the value read is
1402 not a fixed point object, the error handler is invoked.
1404 `std::ostream &operator << (std::ostream &s, const FixedPointComplex &x)'
1405 Send into the stream `s', a formatted fixed point value `x'
1408 File: fixed.info, Node: FPCFunctions, Prev: FPCOperators, Up: FixedPointComplex
1410 2.2.4 `FixedPointComplex' Functions
1411 -----------------------------------
1413 `FixedPoint abs (const FixedPointComplex &x)'
1414 Returns the modulus of `x'
1416 `FixedPoint norm (const FixedPointComplex &x)'
1417 Returns the squared magnitude of `x'
1419 `FixedPoint arg (const FixedPointComplex &x)'
1420 Returns the arc-tangent of `x'
1422 `FixedPointComplex std::polar (const FixedPoint &r, const FixedPoint &p)'
1423 Convert from polar fixed point to a complex fixed point object
1425 `FixedPoint real (const FixedPointComplex &x)'
1426 Returns the real part of `x'
1428 `FixedPoint imag (const FixedPointComplex &x)'
1429 Returns the imaginary part of `x'
1431 `FixedPointComplex conj (const FixedPointComplex &x)'
1432 Returns the conjugate of `x'
1434 `FixedPointComplex cos (const FixedPointComplex &x)'
1435 Returns the transcendental cosine of `x'
1437 `FixedPointComplex cosh (const FixedPointComplex &x)'
1438 Returns the transcendental hyperbolic cosine of `x'
1440 `FixedPointComplex sin (const FixedPointComplex &x)'
1441 Returns the transcendental sine of `x'
1443 `FixedPointComplex sinh (const FixedPointComplex &x)'
1444 Returns the transcendental hyperbolic sine of `x'
1446 `FixedPointComplex tan (const FixedPointComplex &x)'
1447 Returns the transcendental tangent of `x'
1449 `FixedPointComplex tanh (const FixedPointComplex &x)'
1450 Returns the transcendental hyperbolic tangent of `x'
1452 `FixedPointComplex sqrt (const FixedPointComplex &x)'
1453 Returns the square root of `x'
1455 `FixedPointComplex pow (const FixedPointComplex &x, int y)'
1456 `FixedPointComplex pow (const FixedPointComplex &x, const FixedPoint &y)'
1457 `FixedPointComplex pow (const FixedPointComplex &x, const FixedPointComplex &y)'
1458 `FixedPointComplex pow (const FixedPoint &x, const FixedPointComplex &y)'
1459 Returns the `x' raised to the power `y'. Be careful of precision
1460 errors associated with the implementation of this function as a
1463 `FixedPointComplex exp (const FixedPointComplex &x)'
1464 Returns the exponential of `x'. Be careful of precision errors
1465 associated with the implementation of this function as a complex
1468 `FixedPointComplex log (const FixedPointComplex &x)'
1469 Returns the transcendental logarithm of `x'. Be careful of
1470 precision errors associated with the implementation of this
1471 function as a complex type
1473 `FixedPointComplex log10 (const FixedPointComplex &x)'
1474 Returns the transcendental base 10 logarithm of `x'. Be careful of
1475 precision errors associated with the implementation of this
1476 function as a complex type
1478 `FixedPointComplex floor (const FixedPointComplex &x)'
1479 Returns the rounded value of `x' downwards to the nearest integer,
1480 treating the real and imaginary parts separately
1482 `FixedPointComplex ceil (const FixedPointComplex &x)'
1483 Returns the rounded value of `x' upwards to the nearest integer,
1484 treating the real and imaginary parts separately
1486 `FixedPointComplex rint (const FixedPointComplex &x)'
1487 Returns the rounded value of `x' to the nearest integer, treating
1488 the real and imaginary parts separately
1490 `FixedPointComplex round (const FixedPointComplex &x)'
1491 Returns the rounded value of `x' to the nearest integer. The
1492 difference with `rint' is that `0.5' is rounded to `1' and not `0'.
1493 This conforms to the behavior of the octave `round' function.
1494 Treats the real and imaginary parts separately
1497 File: fixed.info, Node: Derived, Next: Upper, Prev: FixedPointComplex, Up: Programming
1499 2.3 The Derived Classes using the Octave Template Classes
1500 =========================================================
1502 It is not the purpose of this section to discuss the use of the Octave
1503 template classes, but rather only the additions to the fixed point
1504 classes that are based on these. For instance the basic constructors
1505 and operations that are available in the normal floating point Octave
1506 classes are available within the fixed point classes.
1508 The notable exceptions are operations involving matrix
1509 decompositions, including inversion, left division, etc. The reason for
1510 this is that the precision of these operators and functions will be
1511 highly implementation dependent. As additional these operators and
1512 functions are used rarely with a fixed point type, there is no point in
1513 implementing these operators and function within the fixed point
1516 In addition the the functions and operators previously described for
1517 the `FixedPoint' and the `FixedPointComplex' types are all available,
1518 in the same from as previously. So these functions are not documented
1519 below. Only the constructors and methods that vary from the previously
1520 described versions are described.
1522 To fully understand these classes, the user is advised to examine the
1523 header files `fixedMatrix.h', `fixedRowVector.h' and `fixedColVector.h'
1524 for the real fixed point objects and `fixedCMatrix.h',
1525 `fixedCRowVector.h' and `fixedCColVector.h' for the complex fixed point
1526 objects. In addition the files `MArray.h' and `MArray2.h' from Octave
1527 should also be examined.
1531 * FixedMatrix:: `FixedMatrix' class
1532 * FixedRowVector:: `FixedRowVector' class
1533 * FixedColumnVector:: `FixedColumnVector' class
1534 * FixedComplexMatrix:: `FixedComplexMatrix' class
1535 * FixedComplexRowVector:: `FixedComplexRowVector' class
1536 * FixedComplexColumnVector:: `FixedComplexColumnVector' class
1539 File: fixed.info, Node: FixedMatrix, Next: FixedRowVector, Prev: Derived, Up: Derived
1541 2.3.1 `FixedMatrix' class
1542 -------------------------
1544 `FixedMatrix::FixedMatrix (const MArray2<int> &is, const MArray2<int> &ds)'
1545 `FixedMatrix::FixedMatrix (const Matrix &is, const Matrix &ds)'
1546 Create a fixed point matrix with the number of bits in the integer
1547 part of each element represented by `is' and the number in the
1548 decimal part by `ds'. The fixed point elements themselves will be
1549 initialized to zero.
1551 `FixedMatrix::FixedMatrix (unsigned int is, unsigned int ds, const FixedMatrix& a)'
1552 `FixedMatrix::FixedMatrix (const MArray2<int> &is, const MArray2<int> &ds, const FixedMatrix& a)'
1553 `FixedMatrix::FixedMatrix (const Matrix &is, const Matrix &ds, const FixedMatrix& a)'
1554 Create a fixed point matrix with the number of bits in the integer
1555 part of each element represented by `is' and the number in the
1556 decimal part by `ds'. The fixed point elements themselves will be
1557 initialized to the fixed point matrix `a'
1559 `FixedMatrix::FixedMatrix (unsigned int is, unsigned int ds, const Matrix& a)'
1560 `FixedMatrix::FixedMatrix (const MArray2<int> &is, const MArray2<int> &ds, const Matrix& a)'
1561 `FixedMatrix::FixedMatrix (const Matrix &is, const Matrix &ds, const Matrix& a)'
1562 Create a fixed point matrix with the number of bits in the integer
1563 part of each element represented by `is' and the number in the
1564 decimal part by `ds'. The fixed point elements themselves will be
1565 initialized to the matrix `a'
1567 `FixedMatrix::FixedMatrix (unsigned int is, unsigned int ds, const Matrix& a, const Matrix& b)'
1568 `FixedMatrix::FixedMatrix (const MArray2<int> &is, const MArray2<int> &ds, const Matrix& a, const Matrix& b)'
1569 `FixedMatrix::FixedMatrix (const Matrix &is, const Matrix &ds, const Matrix& a, const Matrix& b)'
1570 Create a fixed point matrix with the number of bits in the integer
1571 part of each element represented by `is' and the number in the
1572 decimal part by `ds'. The fixed point elements themselves will
1573 have the integer parts loaded by the matrix `a' and the decimal
1574 part by the matrix `b'. It should be noted that `a' and `b' are
1575 both considered as unsigned integers and are the strict
1576 representation of the bits of the fixed point value.
1578 `Matrix FixedMatrix::fixedpoint ()'
1579 Method to create a `Matrix' from a fixed point matrix `x'
1581 `Matrix fixedpoint (const FixedMatrix &x)'
1582 Create a `Matrix' from a fixed point matrix `x'
1584 `Matrix FixedMatrix::sign ()'
1585 Return `-1' for negative numbers, `1' for positive and `0' if the
1586 fixed point element is zero, for every element of the current
1589 `Matrix sign (const FixedMatrix &x)'
1590 Return `-1' for negative numbers, `1' for positive and `0' if
1591 zero, for every element of the fixed point object `x'.
1593 `Matrix FixedMatrix::signbit ()'
1594 Return the sign bit for every element of the current fixed point
1595 matrix (`0' for positive number, `1' for negative number).
1597 `Matrix signbit (const FixedMatrix &x)'
1598 Return the sign bit for every element of the fixed point matrix `x'
1599 (`0' for positive number, `1' for negative number).
1601 `Matrix FixedMatrix::getintsize ()'
1602 Return the number of bit `is' used to represent the integer part
1603 of each element of the current fixed point object.
1605 `Matrix getintsize (const FixedMatrix &x)'
1606 Return the number of bit `is' used to represent the integer part
1607 of each element of the fixed point object `x'.
1609 `Matrix FixedMatrix::getdecsize ()'
1610 Return the number of bit `ds' used to represent the decimal part
1611 of each element of the current fixed point object.
1613 `Matrix getdecsize (const FixedMatrix &x)'
1614 Return the number of bit `ds' used to represent the decimal part
1615 of each element of the fixed point object `x'.
1617 `Matrix FixedMatrix::getnumber ()'
1618 Return the integer representation of the fixed point value of the
1619 each eleement of the current fixed point object.
1621 `Matrix getnumber (const FixedMatrix &x)'
1622 Return the integer representation of the fixed point value of the
1623 each eleement of the fixed point object `x'.
1625 `FixedMatrix FixedMatrix::chintsize (const Matrix &n)'
1626 `FixedMatrix FixedMatrix::chintsize (const double n)'
1627 Return a fixed point object equivalent to the current fixed point
1628 object but with the number of bits representing the integer part
1629 `is' of every element changed to `n'. If the result of this
1630 operation causes any element of `is + ds' to be greater than
1631 `sizeof(int)*8 - 2', the error handler is called.
1633 `FixedMatrix FixedMatrix::chdecsize (const double n)'
1634 `FixedMatrix FixedMatrix::chdecsize (const Matrix &n)'
1635 Return a fixed point object equivalent to the current fixed point
1636 object but with the number of bits representing the decimal part
1637 `ds' of every element changed to `n'. If the result of this
1638 operation causes any element of `is + ds' to be greater than
1639 `sizeof(int)*8 - 2', the error handler is called.
1641 `FixedMatrix FixedMatrix::incintsize (const double n)'
1642 `FixedMatrix FixedMatrix::incintsize (const Matrix &n)'
1643 Return a fixed point object equivalent to the current fixed point
1644 number but with the number of bits representing the integer part
1645 `is' increased by `n'. If `n' is negative, then `is' is decreased.
1646 If the result of this operation causes `is + ds' to be greater than
1647 `sizeof(int)*8 - 2', the error handler is called.
1649 `FixedMatrix FixedMatrix::incintsize ()'
1650 Return a fixed point object equivalent to the current fixed point
1651 number but with the number of bits representing the integer part
1652 `is' increased by 1. If the result of this operation causes `is +
1653 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1656 `FixedMatrix FixedMatrix::incdecsize (const double n)'
1657 `FixedMatrix FixedMatrix::incdecsize (const Matrix &n)'
1658 Return a fixed point object equivalent to the current fixed point
1659 number but with the number of bits representing the decimal part
1660 `ds' increased by `n'. If `n' is negative, then `ds' is decreased.
1661 If the result of this operation causes `is + ds' to be greater than
1662 `sizeof(int)*8 - 2', the error handler is called.
1664 `FixedMatrix FixedMatrix::incdecsize ()'
1665 Return a fixed point object equivalent to the current fixed point
1666 number but with the number of bits representing the decimal part
1667 `ds' increased by 1. If the result of this operation causes `is +
1668 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1672 File: fixed.info, Node: FixedRowVector, Next: FixedColumnVector, Prev: FixedMatrix, Up: Derived
1674 2.3.2 `FixedRowVector' class
1675 ----------------------------
1677 `FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds)'
1678 `FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds)'
1679 Create a fixed point row vector with the number of bits in the
1680 integer part of each element represented by `is' and the number in
1681 the decimal part by `ds'. The fixed point elements themselves will
1682 be initialized to zero.
1684 `FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds, const FixedRowVector& a)'
1685 `FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds, const FixedRowVector& a)'
1686 `FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds, const FixedRowVector& a)'
1687 Create a fixed point row vector with the number of bits in the
1688 integer part of each element represented by `is' and the number in
1689 the decimal part by `ds'. The fixed point elements themselves will
1690 be initialized to the fixed point row rector `a'
1692 `FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds, const RowVector& a)'
1693 `FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds, const RowVector& a)'
1694 `FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds, const RowVector& a)'
1695 Create a fixed point row vector with the number of bits in the
1696 integer part of each element represented by `is' and the number in
1697 the decimal part by `ds'. The fixed point elements themselves will
1698 be initialized to the row vector `a'
1700 `FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds, const RowVector& a, const RowVector& b)'
1701 `FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds, const RowVector& a, const RowVector& b)'
1702 `FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds, const RowVector& a, const RowVector& b)'
1703 Create a fixed point row vector with the number of bits in the
1704 integer part of each element represented by `is' and the number in
1705 the decimal part by `ds'. The fixed point elements themselves will
1706 have the integer parts loaded by the row vector `a' and the
1707 decimal part by the row vector `b'. It should be noted that `a'
1708 and `b' are both considered as unsigned integers and are the
1709 strict representation of the bits of the fixed point value.
1711 `RowVector FixedRowVector::fixedpoint ()'
1712 Method to create a `RowVector' from a fixed point row vector `x'
1714 `RowVector fixedpoint (const FixedRowVector &x)'
1715 Create a `RowVector' from a fixed point row vector `x'
1717 `RowVector FixedRowVector::sign ()'
1718 Return `-1' for negative numbers, `1' for positive and `0' if the
1719 fixed point element is zero, for every element of the current
1722 `RowVector sign (const FixedRowVector &x)'
1723 Return `-1' for negative numbers, `1' for positive and `0' if
1724 zero, for every element of the fixed point object `x'.
1726 `RowVector FixedRowVector::signbit ()'
1727 Return the sign bit for every element of the current fixed point
1728 row vector (`0' for positive number, `1' for negative number).
1730 `RowVector signbit (const FixedRowVector &x)'
1731 Return the sign bit for every element of the fixed point row
1732 vector `x' (`0' for positive number, `1' for negative number).
1734 `RowVector FixedRowVector::getintsize ()'
1735 Return the number of bit `is' used to represent the integer part
1736 of each element of the current fixed point object.
1738 `RowVector getintsize (const FixedRowVector &x)'
1739 Return the number of bit `is' used to represent the integer part
1740 of each element of the fixed point object `x'.
1742 `RowVector FixedRowVector::getdecsize ()'
1743 Return the number of bit `ds' used to represent the decimal part
1744 of each element of the current fixed point object.
1746 `RowVector getdecsize (const FixedRowVector &x)'
1747 Return the number of bit `ds' used to represent the decimal part
1748 of each element of the fixed point object `x'.
1750 `RowVector FixedRowVector::getnumber ()'
1751 Return the integer representation of the fixed point value of the
1752 each eleement of the current fixed point object.
1754 `RowVector getnumber (const FixedRowVector &x)'
1755 Return the integer representation of the fixed point value of the
1756 each eleement of the fixed point object `x'.
1758 `FixedRowVector FixedRowVector::chintsize (const RowVector n)'
1759 `FixedRowVector FixedRowVector::chintsize (const double n)'
1760 Return a fixed point object equivalent to the current fixed point
1761 object but with the number of bits representing the integer part
1762 `is' of every element changed to `n'. If the result of this
1763 operation causes any element of `is + ds' to be greater than
1764 `sizeof(int)*8 - 2', the error handler is called.
1766 `FixedRowVector FixedRowVector::chdecsize (const double n)'
1767 `FixedRowVector FixedRowVector::chdecsize (const RowVector n)'
1768 Return a fixed point object equivalent to the current fixed point
1769 object but with the number of bits representing the decimal part
1770 `ds' of every element changed to `n'. If the result of this
1771 operation causes any element of `is + ds' to be greater than
1772 `sizeof(int)*8 - 2', the error handler is called.
1774 `FixedRowVector FixedRowVector::incintsize (const double n)'
1775 `FixedRowVector FixedRowVector::incintsize (const RowVector &n)'
1776 Return a fixed point object equivalent to the current fixed point
1777 number but with the number of bits representing the integer part
1778 `is' increased by `n'. If `n' is negative, then `is' is decreased.
1779 If the result of this operation causes `is + ds' to be greater than
1780 `sizeof(int)*8 - 2', the error handler is called.
1782 `FixedRowVector FixedRowVector::incintsize ()'
1783 Return a fixed point object equivalent to the current fixed point
1784 number but with the number of bits representing the integer part
1785 `is' increased by 1. If the result of this operation causes `is +
1786 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1789 `FixedRowVector FixedRowVector::incdecsize (const double n)'
1790 `FixedRowVector FixedRowVector::incdecsize (const RowVector &n)'
1791 Return a fixed point object equivalent to the current fixed point
1792 number but with the number of bits representing the decimal part
1793 `ds' increased by `n'. If `n' is negative, then `ds' is decreased.
1794 If the result of this operation causes `is + ds' to be greater than
1795 `sizeof(int)*8 - 2', the error handler is called.
1797 `FixedRowVector FixedRowVector::incdecsize ()'
1798 Return a fixed point object equivalent to the current fixed point
1799 number but with the number of bits representing the decimal part
1800 `ds' increased by 1. If the result of this operation causes `is +
1801 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1805 File: fixed.info, Node: FixedColumnVector, Next: FixedComplexMatrix, Prev: FixedRowVector, Up: Derived
1807 2.3.3 `FixedColumnVector' class
1808 -------------------------------
1810 `FixedColumnVector::FixedColumnVector (const MArray<int> &is, const MArray<int> &ds)'
1811 `FixedColumnVector::FixedColumnVector (const ColumnVector &is, const ColumnVector &ds)'
1812 Create a fixed point row vector with the number of bits in the
1813 integer part of each element represented by `is' and the number in
1814 the decimal part by `ds'. The fixed point elements themselves will
1815 be initialized to zero.
1817 `FixedColumnVector::FixedColumnVector (unsigned int is, unsigned int ds, const FixedColumnVector& a)'
1818 `FixedColumnVector::FixedColumnVector (const MArray<int> &is, const MArray<int> &ds, const FixedColumnVector& a)'
1819 `FixedColumnVector::FixedColumnVector (const ColumnVector &is, const ColumnVector &ds, const FixedColumnVector& a)'
1820 Create a fixed point row vector with the number of bits in the
1821 integer part of each element represented by `is' and the number in
1822 the decimal part by `ds'. The fixed point elements themselves will
1823 be initialized to the fixed point column vector `a'
1825 `FixedColumnVector::FixedColumnVector (unsigned int is, unsigned int ds, const ColumnVector& a)'
1826 `FixedColumnVector::FixedColumnVector (const MArray<int> &is, const MArray<int> &ds, const ColumnVector& a)'
1827 `FixedColumnVector::FixedColumnVector (const ColumnVector &is, const ColumnVector &ds, const ColumnVector& a)'
1828 Create a fixed point row vector with the number of bits in the
1829 integer part of each element represented by `is' and the number in
1830 the decimal part by `ds'. The fixed point elements themselves will
1831 be initialized to the column vector `a'
1833 `FixedColumnVector::FixedColumnVector (unsigned int is, unsigned int ds, const ColumnVector& a, const ColumnVector& b)'
1834 `FixedColumnVector::FixedColumnVector (const MArray<int> &is, const MArray<int> &ds, const ColumnVector& a, const ColumnVector& b)'
1835 `FixedColumnVector::FixedColumnVector (const ColumnVector &is, const ColumnVector &ds, const ColumnVector& a, const ColumnVector& b)'
1836 Create a fixed point row vector with the number of bits in the
1837 integer part of each element represented by `is' and the number in
1838 the decimal part by `ds'. The fixed point elements themselves will
1839 have the integer parts loaded by the column vector `a' and the
1840 decimal part by the column vector `b'. It should be noted that `a'
1841 and `b' are both considered as unsigned integers and are the
1842 strict representation of the bits of the fixed point value.
1844 `ColumnVector FixedColumnVector::fixedpoint ()'
1845 Method to create a `ColumnVector' from a fixed point column vector
1848 `ColumnVector fixedpoint (const FixedColumnVector &x)'
1849 Create a `ColumnVector' from a fixed point column vector `x'
1851 `ColumnVector FixedColumnVector::sign ()'
1852 Return `-1' for negative numbers, `1' for positive and `0' if the
1853 fixed point element is zero, for every element of the current
1856 `ColumnVector sign (const FixedColumnVector &x)'
1857 Return `-1' for negative numbers, `1' for positive and `0' if
1858 zero, for every element of the fixed point object `x'.
1860 `ColumnVector FixedColumnVector::signbit ()'
1861 Return the sign bit for every element of the current fixed point
1862 column vector (`0' for positive number, `1' for negative number).
1864 `ColumnVector signbit (const FixedColumnVector &x)'
1865 Return the sign bit for every element of the fixed point column
1866 vector `x' (`0' for positive number, `1' for negative number).
1868 `ColumnVector FixedColumnVector::getintsize ()'
1869 Return the number of bit `is' used to represent the integer part
1870 of each element of the current fixed point object.
1872 `ColumnVector getintsize (const FixedColumnVector &x)'
1873 Return the number of bit `is' used to represent the integer part
1874 of each element of the fixed point object `x'.
1876 `ColumnVector FixedColumnVector::getdecsize ()'
1877 Return the number of bit `ds' used to represent the decimal part
1878 of each element of the current fixed point object.
1880 `ColumnVector getdecsize (const FixedColumnVector &x)'
1881 Return the number of bit `ds' used to represent the decimal part
1882 of each element of the fixed point object `x'.
1884 `ColumnVector FixedColumnVector::getnumber ()'
1885 Return the integer representation of the fixed point value of the
1886 each eleement of the current fixed point object.
1888 `ColumnVector getnumber (const FixedColumnVector &x)'
1889 Return the integer representation of the fixed point value of the
1890 each eleement of the fixed point object `x'.
1892 `FixedColumnVector FixedColumnVector::chintsize (const ColumnVector n)'
1893 `FixedColumnVector FixedColumnVector::chintsize (const double n)'
1894 Return a fixed point object equivalent to the current fixed point
1895 object but with the number of bits representing the integer part
1896 `is' of every element changed to `n'. If the result of this
1897 operation causes any element of `is + ds' to be greater than
1898 `sizeof(int)*8 - 2', the error handler is called.
1900 `FixedColumnVector FixedColumnVector::chdecsize (const double n)'
1901 `FixedColumnVector FixedColumnVector::chdecsize (const ColumnVector n)'
1902 Return a fixed point object equivalent to the current fixed point
1903 object but with the number of bits representing the decimal part
1904 `ds' of every element changed to `n'. If the result of this
1905 operation causes any element of `is + ds' to be greater than
1906 `sizeof(int)*8 - 2', the error handler is called.
1908 `FixedColumnVector FixedColumnVector::incintsize (const double n)'
1909 `FixedColumnVector FixedColumnVector::incintsize (const ColumnVector &n)'
1910 Return a fixed point object equivalent to the current fixed point
1911 number but with the number of bits representing the integer part
1912 `is' increased by `n'. If `n' is negative, then `is' is decreased.
1913 If the result of this operation causes `is + ds' to be greater than
1914 `sizeof(int)*8 - 2', the error handler is called.
1916 `FixedColumnVector FixedColumnVector::incintsize ()'
1917 Return a fixed point object equivalent to the current fixed point
1918 number but with the number of bits representing the integer part
1919 `is' increased by 1. If the result of this operation causes `is +
1920 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1923 `FixedColumnVector FixedColumnVector::incdecsize (const double n)'
1924 `FixedColumnVector FixedColumnVector::incdecsize (const ColumnVector &n)'
1925 Return a fixed point object equivalent to the current fixed point
1926 number but with the number of bits representing the decimal part
1927 `ds' increased by `n'. If `n' is negative, then `ds' is decreased.
1928 If the result of this operation causes `is + ds' to be greater than
1929 `sizeof(int)*8 - 2', the error handler is called.
1931 `FixedColumnVector FixedColumnVector::incdecsize ()'
1932 Return a fixed point object equivalent to the current fixed point
1933 number but with the number of bits representing the decimal part
1934 `ds' increased by 1. If the result of this operation causes `is +
1935 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
1939 File: fixed.info, Node: FixedComplexMatrix, Next: FixedComplexRowVector, Prev: FixedColumnVector, Up: Derived
1941 2.3.4 `FixedComplexMatrix' class
1942 --------------------------------
1944 `FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, const MArray2<int> &ds)'
1945 `FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds)'
1946 Create a complex fixed point matrix with the number of bits in the
1947 integer part of the real and imaginary part of each element
1948 represented by `is' and the number in the decimal part by `ds'.
1949 The fixed point elements themselves will be initialized to zero.
1951 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds)'
1952 Create a complex fixed point matrix with the number of bits in the
1953 integer part of each element represented by `is' and the number in
1954 the decimal part by `ds'. The fixed point elements themselves will
1955 be initialized to zero.
1957 `FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, const FixedComplexMatrix& a)'
1958 `FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, const FixedComplexMatrix& a)'
1960 `FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, const MArray2<int> &ds, const FixedComplexMatrix& a)'
1961 `FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, const FixedComplexMatrix& a)'
1962 Create a complex fixed point matrix with the number of bits in the
1963 integer part of the real and imaginary part of each element
1964 represented by `is' and the number in the decimal part by `ds'.
1965 The fixed point elements themselves will be initialized to the
1966 complex fixed point matrix `a'
1968 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds, const FixedComplexMatrix &x)'
1969 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds, const FixedMatrix &r, const FixedMatrix &i)'
1970 Create a complex fixed point matrix with the number of bits in the
1971 integer part of each element represented by `is' and the number in
1972 the decimal part by `ds'. The fixed point elements themselves will
1973 be initialized to the complex fixed point matrix `a', or the real
1974 part by `r' and the imaginary by `i'.
1976 `FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, const FixedMatrix& a)'
1977 `FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, const FixedMatrix& a)'
1979 `FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, const MArray2<int> &ds, const FixedMatrix& a)'
1980 `FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, const FixedMatrix& a)'
1981 Create a complex fixed point matrix with the number of bits in the
1982 integer part of the real and imaginary part of each element
1983 represented by `is' and the number in the decimal part by `ds'.
1984 The fixed point elements themselves will be initialized to the
1985 fixed point matrix `a'
1987 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds, const FixedMatrix &x)'
1988 Create a complex fixed point matrix with the number of bits in the
1989 integer part of each element represented by `is' and the number in
1990 the decimal part by `ds'. The fixed point elements themselves will
1991 be initialized to the fixed point matrix `a'.
1993 `FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, const ComplexMatrix& a)'
1994 `FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, const ComplexMatrix& a)'
1995 `FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, const MArray2<int> &ds, const ComplexMatrix& a)'
1996 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds, const ComplexMatrix& a)'
1997 Create a complex fixed point matrix with the number of bits in the
1998 integer part of the real and imaginary part of each element
1999 represented by `is' and the number in the decimal part by `ds'.
2000 The fixed point elements themselves will be initialized to the
2003 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds, const ComplexMatrix &x)'
2004 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds, const Matrix &r, const Matrix &i)'
2005 Create a complex fixed point matrix with the number of bits in the
2006 integer part of each element represented by `is' and the number in
2007 the decimal part by `ds'. The fixed point elements themselves will
2008 be initialized to the complex matrix `a', or the real part by `r'
2009 and the imaginary by `i'.
2011 `FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, const Matrix& a)'
2012 `FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, const Matrix& a)'
2013 `FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, const MArray2<int> &ds, const Matrix& a)'
2014 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds, const Matrix& a)'
2015 Create a complex fixed point matrix with the number of bits in the
2016 integer part of the real and imaginary part of each element
2017 represented by `is' and the number in the decimal part by `ds'.
2018 The fixed point elements themselves will be initialized to the
2021 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds, const Matrix &x)'
2022 Create a complex fixed point matrix with the number of bits in the
2023 integer part of each element represented by `is' and the number in
2024 the decimal part by `ds'. The fixed point elements themselves will
2025 be initialized to the matrix `a'.
2027 `FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, const ComplexMatrix& a, const ComplexMatrix& b)'
2028 `FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, const ComplexMatrix& a, const ComplexMatrix& b)'
2029 `FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, const MArray2<int> &ds, const ComplexMatrix& a, const ComplexMatrix& b)'
2031 `FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, const ComplexMatrix& a, const ComplexMatrix& b)'
2032 `FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, const ComplexMatrix &ds, const ComplexMatrix& a, const ComplexMatrix& b)'
2033 Create a fixed point matrix with the number of bits in the integer
2034 part of each element represented by `is' and the number in the
2035 decimal part by `ds'.The fixed point elements themselves will have
2036 the integer parts loaded by the complex matrix `a' and the decimal
2037 part by the complex matrix `b'. It should be noted that `a' and
2038 `b' are both considered as unsigned complex integers and are the
2039 strict representation of the bits of the fixed point value.
2041 `ComplexMatrix FixedComplexMatrix::fixedpoint ()'
2042 Method to create a `Matrix' from a fixed point matrix `x'
2044 `ComplexMatrix fixedpoint (const FixedComplexMatrix &x)'
2045 Create a `Matrix' from a fixed point matrix `x'
2047 `ComplexMatrix FixedComplexMatrix::sign ()'
2048 Return `-1' for negative numbers, `1' for positive and `0' if the
2049 fixed point element is zero, for every element of the current
2052 `ComplexMatrix sign (const FixedComplexMatrix &x)'
2053 Return `-1' for negative numbers, `1' for positive and `0' if
2054 zero, for every element of the fixed point object `x'.
2056 `ComplexMatrix FixedComplexMatrix::getintsize ()'
2057 Return the number of bit `is' used to represent the integer part
2058 of each element of the current fixed point object.
2060 `ComplexMatrix getintsize (const FixedComplexMatrix &x)'
2061 Return the number of bit `is' used to represent the integer part
2062 of each element of the fixed point object `x'.
2064 `ComplexMatrix FixedComplexMatrix::getdecsize ()'
2065 Return the number of bit `ds' used to represent the decimal part
2066 of each element of the current fixed point object.
2068 `ComplexMatrix getdecsize (const FixedComplexMatrix &x)'
2069 Return the number of bit `ds' used to represent the decimal part
2070 of each element of the fixed point object `x'.
2072 `ComplexMatrix FixedComplexMatrix::getnumber ()'
2073 Return the integer representation of the fixed point value of the
2074 each eleement of the current fixed point object.
2076 `ComplexMatrix getnumber (const FixedComplexMatrix &x)'
2077 Return the integer representation of the fixed point value of the
2078 each eleement of the fixed point object `x'.
2080 `FixedComplexMatrix FixedComplexMatrix::chintsize (const ComplexMatrix &n)'
2081 `FixedComplexMatrix FixedComplexMatrix::chintsize (const double n)'
2082 Return a fixed point object equivalent to the current fixed point
2083 object but with the number of bits representing the integer part
2084 `is' of every element changed to `n'. If the result of this
2085 operation causes any element of `is + ds' to be greater than
2086 `sizeof(int)*8 - 2', the error handler is called.
2088 `FixedComplexMatrix FixedComplexMatrix::chdecsize (const double n)'
2089 `FixedComplexMatrix FixedComplexMatrix::chdecsize (const ComplexMatrix &n)'
2090 Return a fixed point object equivalent to the current fixed point
2091 object but with the number of bits representing the decimal part
2092 `ds' of every element changed to `n'. If the result of this
2093 operation causes any element of `is + ds' to be greater than
2094 `sizeof(int)*8 - 2', the error handler is called.
2096 `FixedComplexMatrix FixedComplexMatrix::incintsize (const double n)'
2097 `FixedComplexMatrix FixedComplexMatrix::incintsize (const ComplexMatrix &n)'
2098 Return a fixed point object equivalent to the current fixed point
2099 number but with the number of bits representing the integer part
2100 `is' increased by `n'. If `n' is negative, then `is' is decreased.
2101 If the result of this operation causes `is + ds' to be greater than
2102 `sizeof(int)*8 - 2', the error handler is called.
2104 `FixedComplexMatrix FixedComplexMatrix::incintsize ()'
2105 Return a fixed point object equivalent to the current fixed point
2106 number but with the number of bits representing the integer part
2107 `is' increased by 1. If the result of this operation causes `is +
2108 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
2111 `FixedComplexMatrix FixedComplexMatrix::incdecsize (const double n)'
2112 `FixedComplexMatrix FixedComplexMatrix::incdecsize (const ComplexMatrix &n)'
2113 Return a fixed point object equivalent to the current fixed point
2114 number but with the number of bits representing the decimal part
2115 `ds' increased by `n'. If `n' is negative, then `ds' is decreased.
2116 If the result of this operation causes `is + ds' to be greater than
2117 `sizeof(int)*8 - 2', the error handler is called.
2119 `FixedComplexMatrix FixedComplex::incdecsize ()'
2120 Return a fixed point object equivalent to the current fixed point
2121 number but with the number of bits representing the decimal part
2122 `ds' increased by 1. If the result of this operation causes `is +
2123 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
2127 File: fixed.info, Node: FixedComplexRowVector, Next: FixedComplexColumnVector, Prev: FixedComplexMatrix, Up: Derived
2129 2.3.5 `FixedComplexRowVector' class
2130 -----------------------------------
2132 `FixedComplexRowVector::FixedComplexRowVector (const MArray<int> &is, const MArray<int> &ds)'
2133 `FixedComplexRowVector::FixedComplexRowVector (const RowVector &is, const RowVector &ds)'
2134 Create a complex fixed point row vector with the number of bits in
2135 the integer part of the real and imaginary part of each element
2136 represented by `is' and the number in the decimal part by `ds'.
2137 The fixed point elements themselves will be initialized to zero.
2139 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds)'
2140 Create a complex fixed point row vector with the number of bits in
2141 the integer part of each element represented by `is' and the
2142 number in the decimal part by `ds'. The fixed point elements
2143 themselves will be initialized to zero.
2145 `FixedComplexRowVector::FixedComplexRowVector (unsigned int is, unsigned int ds, const FixedComplexRowVector& a)'
2146 `FixedComplexRowVector::FixedComplexRowVector (Complex is, Complex ds, const FixedComplexRowVector& a)'
2147 `FixedComplexRowVector::FixedComplexRowVector (const MArray<int> &is, const MArray<int> &ds, const FixedComplexRowVector& a)'
2148 `FixedComplexRowVector::FixedComplexRowVector (const RowVector &is, const RowVector &ds, const FixedComplexRowVector& a)'
2149 Create a complex fixed point row vector with the number of bits in
2150 the integer part of the real and imaginary part of each element
2151 represented by `is' and the number in the decimal part by `ds'.
2152 The fixed point elements themselves will be initialized to the
2153 complex fixed point row vector `a'
2155 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds, const FixedComplexRowVector &x)'
2156 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds, const FixedRowVector &r, const FixedRowVector &i)'
2157 Create a complex fixed point row vector with the number of bits in
2158 the integer part of each element represented by `is' and the
2159 number in the decimal part by `ds'. The fixed point elements
2160 themselves will be initialized to the complex fixed point row
2161 vector `a', or the real part by `r' and the imaginary by `i'.
2163 `FixedComplexRowVector::FixedComplexRowVector (unsigned int is, unsigned int ds, const FixedRowVector& a)'
2164 `FixedComplexRowVector::FixedComplexRowVector (Complex is, Complex ds, const FixedRowVector& a)'
2165 `FixedComplexRowVector::FixedComplexRowVector (const MArray<int> &is, const MArray<int> &ds, const FixedRowVector& a)'
2166 `FixedComplexRowVector::FixedComplexRowVector (const RowVector &is, const RowVector &ds, const FixedRowVector& a)'
2167 Create a complex fixed point row vector with the number of bits in
2168 the integer part of the real and imaginary part of each element
2169 represented by `is' and the number in the decimal part by `ds'.
2170 The fixed point elements themselves will be initialized to the
2171 fixed point row vector `a'
2173 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds, const FixedRowVector &x)'
2174 Create a complex fixed point row vector with the number of bits in
2175 the integer part of each element represented by `is' and the
2176 number in the decimal part by `ds'. The fixed point elements
2177 themselves will be initialized to the fixed point row vector `a'.
2179 `FixedComplexRowVector::FixedComplexRowVector (unsigned int is, unsigned int ds, const ComplexRowVector& a)'
2180 `FixedComplexRowVector::FixedComplexRowVector (Complex is, Complex ds, const ComplexRowVector& a)'
2181 `FixedComplexRowVector::FixedComplexRowVector (const MArray<int> &is, const MArray<int> &ds, const ComplexRowVector& a)'
2182 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds, const ComplexRowVector& a)'
2183 Create a complex fixed point row vector with the number of bits in
2184 the integer part of the real and imaginary part of each element
2185 represented by `is' and the number in the decimal part by `ds'.
2186 The fixed point elements themselves will be initialized to the
2187 complex row vector `a'
2189 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds, const ComplexRowVector &x)'
2190 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds, const RowVector &r, const RowVector &i)'
2191 Create a complex fixed point row vector with the number of bits in
2192 the integer part of each element represented by `is' and the
2193 number in the decimal part by `ds'. The fixed point elements
2194 themselves will be initialized to the complex row vector `a', or
2195 the real part by `r' and the imaginary by `i'.
2197 `FixedComplexRowVector::FixedComplexRowVector (unsigned int is, unsigned int ds, const RowVector& a)'
2198 `FixedComplexRowVector::FixedComplexRowVector (Complex is, Complex ds, const RowVector& a)'
2199 `FixedComplexRowVector::FixedComplexRowVector (const MArray<int> &is, const MArray<int> &ds, const RowVector& a)'
2200 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds, const RowVector& a)'
2201 Create a complex fixed point row vector with the number of bits in
2202 the integer part of the real and imaginary part of each element
2203 represented by `is' and the number in the decimal part by `ds'.
2204 The fixed point elements themselves will be initialized to the row
2207 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds, const RowVector &x)'
2208 Create a complex fixed point row vector with the number of bits in
2209 the integer part of each element represented by `is' and the
2210 number in the decimal part by `ds'. The fixed point elements
2211 themselves will be initialized to the row vector `a'.
2213 `FixedComplexRowVector::FixedComplexRowVector (unsigned int is, unsigned int ds, const ComplexRowVector& a, const ComplexRowVector& b)'
2214 `FixedComplexRowVector::FixedComplexRowVector (Complex is, Complex ds, const ComplexRowVector& a, const ComplexRowVector& b)'
2215 `FixedComplexRowVector::FixedComplexRowVector (const MArray<int> &is, const MArray<int> &ds, const ComplexRowVector& a, const ComplexRowVector& b)'
2216 `FixedComplexRowVector::FixedComplexRowVector (const RowVector &is, const RowVector &ds, const ComplexRowVector& a, const ComplexRowVector& b)'
2217 `FixedComplexRowVector::FixedComplexRowVector (const ComplexRowVector &is, const ComplexRowVector &ds, const ComplexRowVector& a, const ComplexRowVector& b)'
2218 Create a fixed point row vector with the number of bits in the
2219 integer part of each element represented by `is' and the number in
2220 the decimal part by `ds'. The fixed point elements themselves will
2221 have the integer parts loaded by the complex row vector `a' and
2222 the decimal part by the complex row vector `b'. It should be noted
2223 that `a' and `b' are both considered as unsigned complex integers
2224 and are the strict representation of the bits of the fixed point
2227 `ComplexRowVector FixedComplexRowVector::fixedpoint ()'
2228 Method to create a `RowVector' from a fixed point row vector `x'
2230 `ComplexRowVector fixedpoint (const FixedComplexRowVector &x)'
2231 Create a `RowVector' from a fixed point row vector `x'
2233 `ComplexRowVector FixedComplexRowVector::sign ()'
2234 Return `-1' for negative numbers, `1' for positive and `0' if the
2235 fixed point element is zero, for every element of the current
2238 `ComplexRowVector sign (const FixedComplexRowVector &x)'
2239 Return `-1' for negative numbers, `1' for positive and `0' if
2240 zero, for every element of the fixed point object `x'.
2242 `ComplexRowVector FixedComplexRowVector::getintsize ()'
2243 Return the number of bit `is' used to represent the integer part
2244 of each element of the current fixed point object.
2246 `ComplexRowVector getintsize (const FixedComplexRowVector &x)'
2247 Return the number of bit `is' used to represent the integer part
2248 of each element of the fixed point object `x'.
2250 `ComplexRowVector FixedComplexRowVector::getdecsize ()'
2251 Return the number of bit `ds' used to represent the decimal part
2252 of each element of the current fixed point object.
2254 `ComplexRowVector getdecsize (const FixedComplexRowVector &x)'
2255 Return the number of bit `ds' used to represent the decimal part
2256 of each element of the fixed point object `x'.
2258 `ComplexRowVector getdecsize (const FixedComplexRowVector &x)'
2259 Return the number of bit `ds' used to represent the decimal part
2260 of each element of the fixed point object `x'.
2262 `ComplexRowVector FixedComplexRowVector::getnumber ()'
2263 Return the integer representation of the fixed point value of the
2264 each eleement of the current fixed point object.
2266 `FixedComplexRowVector FixedComplexRowVector::chintsize (const ComplexRowVector &n)'
2267 `FixedComplexRowVector FixedComplexRowVector::chintsize (const double n)'
2268 Return a fixed point object equivalent to the current fixed point
2269 object but with the number of bits representing the integer part
2270 `is' of every element changed to `n'. If the result of this
2271 operation causes any element of `is + ds' to be greater than
2272 `sizeof(int)*8 - 2', the error handler is called.
2274 `FixedComplexRowVector FixedComplexRowVector::chdecsize (const double n)'
2275 `FixedComplexRowVector FixedComplexRowVector::chdecsize (const ComplexRowVector &n)'
2276 Return a fixed point object equivalent to the current fixed point
2277 object but with the number of bits representing the decimal part
2278 `ds' of every element changed to `n'. If the result of this
2279 operation causes any element of `is + ds' to be greater than
2280 `sizeof(int)*8 - 2', the error handler is called.
2282 `FixedComplexRowVector FixedComplexRowVector::incintsize (const Complex n)'
2283 `FixedComplexRowVector FixedComplexRowVector::incintsize (const ComplexRowVector &n)'
2284 Return a fixed point object equivalent to the current fixed point
2285 number but with the number of bits representing the integer part
2286 `is' increased by `n'. If `n' is negative, then `is' is decreased.
2287 If the result of this operation causes `is + ds' to be greater than
2288 `sizeof(int)*8 - 2', the error handler is called.
2290 `FixedComplexRowVector FixedComplexRowVector::incintsize ()'
2291 Return a fixed point object equivalent to the current fixed point
2292 number but with the number of bits representing the integer part
2293 `is' increased by 1. If the result of this operation causes `is +
2294 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
2297 `FixedComplexRowVector FixedComplexRowVector::incdecsize (const Complex n)'
2298 `FixedComplexRowVector FixedComplexRowVector::incdecsize (const ComplexRowVector &n)'
2299 Return a fixed point object equivalent to the current fixed point
2300 number but with the number of bits representing the decimal part
2301 `ds' increased by `n'. If `n' is negative, then `ds' is decreased.
2302 If the result of this operation causes `is + ds' to be greater than
2303 `sizeof(int)*8 - 2', the error handler is called.
2305 `FixedComplexRowVector FixedComplexRowVector::incdecsize ()'
2306 Return a fixed point object equivalent to the current fixed point
2307 number but with the number of bits representing the decimal part
2308 `ds' increased by 1. If the result of this operation causes `is +
2309 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
2313 File: fixed.info, Node: FixedComplexColumnVector, Prev: FixedComplexRowVector, Up: Derived
2315 2.3.6 `FixedComplexColumnVector' class
2316 --------------------------------------
2318 `FixedComplexColumnVector::FixedComplexColumnVector (const MArray<int> &is, const MArray<int> &ds)'
2319 `FixedComplexColumnVector::FixedComplexColumnVector (const ColumnVector &is, const ColumnVector &ds)'
2320 Create a complex fixed point column vector with the number of bits
2321 in the integer part of the real and imaginary part of each element
2322 represented by `is' and the number in the decimal part by `ds'.
2323 The fixed point elements themselves will be initialized to zero.
2325 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds)'
2326 Create a complex fixed point column vector with the number of bits
2327 in the integer part of each element represented by `is' and the
2328 number in the decimal part by `ds'. The fixed point elements
2329 themselves will be initialized to zero.
2331 `FixedComplexColumnVector::FixedComplexColumnVector (unsigned int is, unsigned int ds, const FixedComplexColumnVector& a)'
2332 `FixedComplexColumnVector::FixedComplexColumnVector (Complex is, Complex ds, const FixedComplexColumnVector& a)'
2333 `FixedComplexColumnVector::FixedComplexColumnVector (const MArray<int> &is, const MArray<int> &ds, const FixedComplexColumnVector& a)'
2334 `FixedComplexColumnVector::FixedComplexColumnVector (const ColumnVector &is, const ColumnVector &ds, const FixedComplexColumnVector& a)'
2335 Create a complex fixed point column vector with the number of bits
2336 in the integer part of the real and imaginary part of each element
2337 represented by `is' and the number in the decimal part by `ds'.
2338 The fixed point elements themselves will be initialized to the
2339 complex fixed point column vector `a'
2341 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds, const FixedComplexColumnVector &x)'
2342 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds, const FixedColumnVector &r, const FixedColumnVector &i)'
2343 Create a complex fixed point column vector with the number of bits
2344 in the integer part of each element represented by `is' and the
2345 number in the decimal part by `ds'. The fixed point elements
2346 themselves will be initialized to the complex fixed point column
2347 vector `a', or the real part by `r' and the imaginary by `i'.
2349 `FixedComplexColumnVector::FixedComplexColumnVector (unsigned int is, unsigned int ds, const FixedColumnVector& a)'
2350 `FixedComplexColumnVector::FixedComplexColumnVector (Complex is, Complex ds, const FixedColumnVector& a)'
2351 `FixedComplexColumnVector::FixedComplexColumnVector (const MArray<int> &is, const MArray<int> &ds, const FixedColumnVector& a)'
2352 `FixedComplexColumnVector::FixedComplexColumnVector (const ColumnVector &is, const ColumnVector &ds, const FixedColumnVector& a)'
2353 Create a complex fixed point column vector with the number of bits
2354 in the integer part of the real and imaginary part of each element
2355 represented by `is' and the number in the decimal part by `ds'.
2356 The fixed point elements themselves will be initialized to the
2357 fixed point column vector `a'
2359 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds, const FixedColumnVector &x)'
2360 Create a complex fixed point column vector with the number of bits
2361 in the integer part of each element represented by `is' and the
2362 number in the decimal part by `ds'. The fixed point elements
2363 themselves will be initialized to the fixed point column vector
2366 `FixedComplexColumnVector::FixedComplexColumnVector (unsigned int is, unsigned int ds, const ComplexColumnVector& a)'
2367 `FixedComplexColumnVector::FixedComplexColumnVector (Complex is, Complex ds, const ComplexColumnVector& a)'
2368 `FixedComplexColumnVector::FixedComplexColumnVector (const MArray<int> &is, const MArray<int> &ds, const ComplexColumnVector& a)'
2369 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds, const ComplexColumnVector& a)'
2370 Create a complex fixed point column vector with the number of bits
2371 in the integer part of the real and imaginary part of each element
2372 represented by `is' and the number in the decimal part by `ds'.
2373 The fixed point elements themselves will be initialized to the
2374 complex column vector `a'
2376 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds, const ComplexColumnVector &x)'
2377 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds, const ColumnVector &r, const ColumnVector &i)'
2378 Create a complex fixed point column vector with the number of bits
2379 in the integer part of each element represented by `is' and the
2380 number in the decimal part by `ds'. The fixed point elements
2381 themselves will be initialized to the complex column vector `a',
2382 or the real part by `r' and the imaginary by `i'.
2384 `FixedComplexColumnVector::FixedComplexColumnVector (unsigned int is, unsigned int ds, const ColumnVector& a)'
2385 `FixedComplexColumnVector::FixedComplexColumnVector (Complex is, Complex ds, const ColumnVector& a)'
2387 `FixedComplexColumnVector::FixedComplexColumnVector (const MArray<int> &is, const MArray<int> &ds, const ColumnVector& a)'
2388 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds, const ColumnVector& a)'
2389 Create a complex fixed point column vector with the number of bits
2390 in the integer part of the real and imaginary part of each element
2391 represented by `is' and the number in the decimal part by `ds'.
2392 The fixed point elements themselves will be initialized to the
2395 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds, const ColumnVector &x)'
2396 Create a complex fixed point column vector with the number of bits
2397 in the integer part of each element represented by `is' and the
2398 number in the decimal part by `ds'. The fixed point elements
2399 themselves will be initialized to the column vector `a'.
2401 `FixedComplexColumnVector::FixedComplexColumnVector (unsigned int is, unsigned int ds, const ComplexColumnVector& a, const ComplexColumnVector& b)'
2402 `FixedComplexColumnVector::FixedComplexColumnVector (Complex is, Complex ds, const ComplexColumnVector& a, const ComplexColumnVector& b)'
2403 `FixedComplexColumnVector::FixedComplexColumnVector (const MArray<int> &is, const MArray<int> &ds, const ComplexColumnVector& a, const ComplexColumnVector& b)'
2404 `FixedComplexColumnVector::FixedComplexColumnVector (const ColumnVector &is, const ColumnVector &ds, const ComplexColumnVector& a, const ComplexColumnVector& b)'
2405 `FixedComplexColumnVector::FixedComplexColumnVector (const ComplexColumnVector &is, const ComplexColumnVector &ds, const ComplexColumnVector& a, const ComplexColumnVector& b)'
2406 Create a fixed point column vector with the number of bits in the
2407 integer part of each element represented by `is' and the number in
2408 the decimal part by `ds'. The fixed point elements themselves will
2409 have the integer parts loaded by the complex column vector `a' and
2410 the decimal part by the compelx column vector `b'. It should be
2411 noted that `a' and `b' are both considered as unsigned compelx
2412 integers and are the strict representation of the bits of the
2415 `ComplexColumnVector FixedComplexColumnVector::fixedpoint ()'
2416 Method to create a `ColumnVector' from a fixed point column vector
2419 `ComplexColumnVector fixedpoint (const FixedComplexColumnVector &x)'
2420 Create a `ColumnVector' from a fixed point column vector `x'
2422 `ComplexColumnVector FixedComplexColumnVector::sign ()'
2423 Return `-1' for negative numbers, `1' for positive and `0' if the
2424 fixed point element is zero, for every element of the current
2427 `ComplexColumnVector sign (const FixedComplexColumnVector &x)'
2428 Return `-1' for negative numbers, `1' for positive and `0' if
2429 zero, for every element of the fixed point object `x'.
2431 `ComplexColumnVector FixedComplexColumnVector::getintsize ()'
2432 Return the number of bit `is' used to represent the integer part
2433 of each element of the current fixed point object.
2435 `ComplexColumnVector getintsize (const FixedComplexColumnVector &x)'
2436 Return the number of bit `is' used to represent the integer part
2437 of each element of the fixed point object `x'.
2439 `ComplexColumnVector FixedComplexColumnVector::getdecsize ()'
2440 Return the number of bit `ds' used to represent the decimal part
2441 of each element of the current fixed point object.
2443 `ComplexColumnVector getdecsize (const FixedComplexColumnVector &x)'
2444 Return the number of bit `ds' used to represent the decimal part
2445 of each element of the fixed point object `x'.
2447 `ComplexColumnVector FixedComplexColumnVector::getnumber ()'
2448 Return the integer representation of the fixed point value of the
2449 each eleement of the current fixed point object.
2451 `ComplexColumnVector getnumber (const FixedComplexColumnVector &x)'
2452 Return the integer representation of the fixed point value of the
2453 each eleement of the fixed point object `x'.
2455 `FixedComplexColumnVector FixedComplexColumnVector::chintsize (const ComplexColumnVector &n)'
2456 `FixedComplexColumnVector FixedComplexColumnVector::chintsize (const double n)'
2457 Return a fixed point object equivalent to the current fixed point
2458 object but with the number of bits representing the integer part
2459 `is' of every element changed to `n'. If the result of this
2460 operation causes any element of `is + ds' to be greater than
2461 `sizeof(int)*8 - 2', the error handler is called.
2463 `FixedComplexColumnVector FixedComplexColumnVector::chdecsize (const double n)'
2464 `FixedComplexColumnVector FixedComplexColumnVector::chdecsize (const ComplexColumnVector &n)'
2465 Return a fixed point object equivalent to the current fixed point
2466 object but with the number of bits representing the decimal part
2467 `ds' of every element changed to `n'. If the result of this
2468 operation causes any element of `is + ds' to be greater than
2469 `sizeof(int)*8 - 2', the error handler is called.
2471 `FixedComplexColumnVector FixedComplexColumnVector::incintsize (const double n)'
2472 `FixedComplexColumnVector FixedComplexColumnVector::incintsize (const ComplexColumnVector &n)'
2473 Return a fixed point object equivalent to the current fixed point
2474 number but with the number of bits representing the integer part
2475 `is' increased by `n'. If `n' is negative, then `is' is decreased.
2476 If the result of this operation causes `is + ds' to be greater than
2477 `sizeof(int)*8 - 2', the error handler is called.
2479 `FixedComplexColumnVector FixedComplexColumnVector::incintsize ()'
2480 Return a fixed point object equivalent to the current fixed point
2481 number but with the number of bits representing the integer part
2482 `is' increased by 1. If the result of this operation causes `is +
2483 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
2486 `FixedComplexColumnVector FixedComplexColumnVector::incdecsize (const double n)'
2487 `FixedComplexColumnVector FixedComplexColumnVector::incdecsize (const ComplexColumnVector &n)'
2488 Return a fixed point object equivalent to the current fixed point
2489 number but with the number of bits representing the decimal part
2490 `ds' increased by `n'. If `n' is negative, then `ds' is decreased.
2491 If the result of this operation causes `is + ds' to be greater than
2492 `sizeof(int)*8 - 2', the error handler is called.
2494 `FixedComplexColumnVector FixedComplexColumnVector::incdecsize ()'
2495 Return a fixed point object equivalent to the current fixed point
2496 number but with the number of bits representing the decimal part
2497 `ds' increased by 1. If the result of this operation causes `is +
2498 ds' to be greater than `sizeof(int)*8 - 2', the error handler is
2502 File: fixed.info, Node: Upper, Next: Oct-files, Prev: Derived, Up: Programming
2504 2.4 The Upper Level Octave Classes
2505 ==================================
2507 There are 4 upper level classes that define the interface of the fixed
2508 point type to the octave interpreter. These mirror similar definitions
2509 for floating values in octave and are
2511 `octave_fixed' -> `octave_scalar'
2512 `octave_fixed_complex' -> `octave_complex'
2513 `octave_fixed_matrix' -> `octave_matrix'
2514 `octave_fixed_complex_matrix' -> `octave_complex_matrix'
2516 These fixed point classes use the same base classes as the
2517 corresponding floating classes, and so have similar capabilities.
2518 However, one notable addition are the methods to obtain the base fixed
2519 point objects from these classes, and also correspond to similar
2520 floating point methods. These are
2522 `fixed_value' -> `scalar_value'
2523 `fixed_complex_value' -> `complex_value'
2524 `fixed_matrix_value' -> `matrix_value'
2525 `fixed_complex_matrix_value' -> `complex_matrix_value'
2527 and can be used in all fixed point classes, subject to a possible
2528 reduction operations (eg. casts a `FixedComplexMatrix' as a
2529 `FixedPoint'). In addition the methods `scalar_value', `complex_value',
2530 `matrix_value' and `complex_matrix_value' can all be used.
2532 The user should examine the files `ov-fixed-cx-mat.h',
2533 `ov-fixed-complex.h', `ov-fixed-mat.h' and `ov-fixed.h' and the base
2534 classes in the files `ov-base-fixed.h', `ov-base-fixed-mat.h', and
2535 file `ov-base.h' within octave to see the methods that are available
2536 for the upper level classes.
2539 File: fixed.info, Node: Oct-files, Prev: Upper, Up: Programming
2541 2.5 Writing Oct-files with the Fixed Point Type
2542 ===============================================
2544 It is not the purpose of this section to discuss how to write an
2545 oct-file, or discuss what they are, but rather the specifics of using
2546 oct-files with the fixed point type. An oct-file is a means of writing
2547 an octave function in a compilable language like C++, rather than as a
2548 script file. This results in a significant acceleration in the code.
2549 The reader is referred to the tutorial available at
2550 `http://octave.sourceforge.net/coda/coda.html'. The examples discussed
2551 here assume that the oct-file is written entirely in C++.
2555 * Templates:: Using C++ Templates in Oct-files
2556 * Problems:: Specific Problems of Oct-files using Fixed Point
2557 * Cygwin:: Specific points to note when using Oct-files and Cygwin
2558 * OctExample:: A Simple Example of an Oct-file
2561 File: fixed.info, Node: Templates, Next: Problems, Prev: Oct-files, Up: Oct-files
2563 2.5.1 Using C++ Templates in Oct-files
2564 --------------------------------------
2566 When using the fixed point toolbox, you will almost certainly want to
2567 compare an implementation in fixed-point against the corresponding
2568 implementation in floating point. This allows the degradation due to
2569 the conversion to a fixed-point algorithm to be easily observed. The
2570 concept of C++ templates allows easy implementation of both fixed and
2571 floating point versions of the same code. For example consider
2573 template <class A, class B>
2574 A myfunc(const A &a, const B &b) {
2578 // Floating point instantiations
2579 template double myfunc (const double&, const double&);
2580 template Complex myfunc (const Complex&, const double&);
2581 template Matrix myfunc (const Matrix&, const double&);
2582 template ComplexMatrix myfunc (const ComplexMatrix&, const double&);
2584 // Fixed point instantiations
2585 template FixedPoint myfunc (const FixedPoint&, const FixedPoint&);
2586 template FixedPointComplex myfunc (const FixedPointComplex&,
2588 template FixedMatrix myfunc (const FixedMatrix&, const FixedPoint&);
2589 template FixedComplexMatrix myfunc (const FixedComplexMatrix&,
2592 Eight versions of the function `myfunc' are created, that allow its
2593 use with all floating and fixed types.
2596 File: fixed.info, Node: Problems, Next: Cygwin, Prev: Templates, Up: Oct-files
2598 2.5.2 Specific Problems of Oct-files using Fixed Point
2599 ------------------------------------------------------
2601 The fact that the fixed point type is loadable, means that the symbols
2602 of this type are not available till the first use of a fixed point
2603 variable. This means that the function "fixed" must be called at least
2604 once prior to accessing fixed point values in an oct-file. If a user
2605 function is called, that uses a fixed point type, before the type is
2606 loaded the result will be an error message complaining of unknown
2607 symbols. For example
2609 octave:1> fixed_inc(a)
2610 error: /home/dbateman/octave/fixed/fixed_inc.oct: undefined symbol:
2611 _ZN24octave_base_fixed_matrixI18FixedComplexMatrixE7subsref
2612 ERKSsRKSt4listI17octave_value_listSaIS5_EE
2613 error: `fixed_inc' undefined near line 1 column 1
2615 This should not in itself result in an abnormal exit from Octave.
2617 Another problem when accessing fixed point variables within
2618 oct-files, is that the Octave `octave_value' class knows nothing about
2619 this type. So you can not directly call a method such as
2620 `fixed_value()' on the input arguments, but rather must cast the
2621 representation of the `octave_value' as a fixed type and then call the
2622 relevant method. An example of extracting a fixed point value from an
2623 `octave_value' variable `arg' is then
2627 if (arg.type_id () == octave_fixed::static_type_id ()) {
2628 FixedPoint f = ((const octave_fixed&) arg.get_rep()).fixed_value();
2630 Similarly, the return value from an oct-file is itself either an
2631 `octave_value' or an `octave_value_list'. So a special means of
2632 creating the return value must be used. For example
2634 octave_value_list retval;
2638 retval(0) = octave_value(m);
2639 retval(1) = new octave_fixed (f);
2642 File: fixed.info, Node: Cygwin, Next: OctExample, Prev: Problems, Up: Oct-files
2644 2.5.3 Specific points to note when using Oct-files and Cygwin
2645 -------------------------------------------------------------
2647 When using the GNU C++ compiler under Cygwin to create a shared object,
2648 such as an oct-file, the symbols must be resolved at compile time. This
2649 is as opposed to a Unix platform where the resolution of the symbols
2650 can be left till runtime. For this reason the fixed point type, when
2651 built under Cygwin is split into an oct-file and a shared library
2652 called `liboctave_fixed.dll'. This is as opposed to the situation under
2653 Unix, where only the Oct-file containing all of the fixed point type is
2656 This has the implication that when you build an Oct-file under Cygwin
2657 using the fixed point type, that they must be linked to
2658 `liboctave_fixed.dll'. An appropriate means to do this is for example
2660 % mkoctfile -loctave_fixed myfile.cc
2662 The file `liboctave_fixed.dll' and `liboctave_fixed.dll.a' must be
2663 located somewhere that the compiler can find them. If these are
2664 installed in the same directory as `liboctave.dll' and
2665 `liboctave.dll.a' respectively, then `mkoctfile' will find them
2669 File: fixed.info, Node: OctExample, Prev: Cygwin, Up: Oct-files
2671 2.5.4 A Simple Example of an Oct-file
2672 -------------------------------------
2674 An example of a simple oct-file written in C++ using the fixed point
2675 type can be seen below. It integrates the ideas discussed previously.
2677 #include <octave/config.h>
2678 #include <octave/oct.h>
2681 template <class A, class B>
2682 A myfunc(const A &a, const B &b) {
2686 // Floating point instantiations
2687 template double myfunc (const double&, const double&);
2688 template Complex myfunc (const Complex&, const double&);
2689 template Matrix myfunc (const Matrix&, const double&);
2690 template ComplexMatrix myfunc (const ComplexMatrix&, const double&);
2692 // Fixed point instantiations
2693 template FixedPoint myfunc (const FixedPoint&, const FixedPoint&);
2694 template FixedPointComplex myfunc (const FixedPointComplex&,
2696 template FixedMatrix myfunc (const FixedMatrix&, const FixedPoint&);
2697 template FixedComplexMatrix myfunc (const FixedComplexMatrix&,
2700 DEFUN_DLD (fixed_inc, args, ,
2702 @deftypefn {Loadable Function} {@var{y} =} fixed_inc (@var{x})\n\
2703 Example code of the use of the fixed point types in an oct-file.\n\
2704 Returns @code{@var{x} + 1}\n\
2707 octave_value retval;
2708 FixedPoint one(1,0,1,0); // Fixed Point value of 1
2710 if (args.length() != 1)
2711 print_usage("fixed_inc");
2713 if (args(0).type_id () == octave_fixed_matrix::static_type_id ()) {
2714 FixedMatrix f = ((const octave_fixed_matrix&) args(0).get_rep()).
2715 fixed_matrix_value();
2716 retval = new octave_fixed_matrix (myfunc(f,one));
2717 } else if (args(0).type_id () == octave_fixed::static_type_id ()) {
2718 FixedPoint f = ((const octave_fixed&) args(0).get_rep()).
2720 retval = new octave_fixed (myfunc(f,one));
2721 } else if (args(0).type_id () ==
2722 octave_fixed_complex::static_type_id ()) {
2723 FixedPointComplex f = ((const octave_fixed_complex&)
2724 args(0).get_rep()).fixed_complex_value();
2725 retval = new octave_fixed_complex (myfunc(f,one));
2726 } else if (args(0).type_id () ==
2727 octave_fixed_complex_matrix::static_type_id ()) {
2728 FixedComplexMatrix f = ((const octave_fixed_complex_matrix&)
2729 args(0).get_rep()).fixed_complex_matrix_value();
2730 retval = new octave_fixed_complex_matrix (myfunc(f,one));
2732 // promote the operation to complex matrix. The narrowing op in
2733 // octave_value will later change the type if needed. This is not
2734 // optimal but is convenient....
2735 ComplexMatrix f = args(0).complex_matrix_value();
2736 retval = octave_value (myfunc(f,1.));
2742 File: fixed.info, Node: Example, Next: Function Reference, Prev: Programming, Up: Top
2744 3 Fixed Point Type Applied to Real Signal Processing Example
2745 ************************************************************
2747 As an example of the use of the fixed point toolbox applied to a real
2748 signal processing example, we consider the implementation of a Radix-4
2749 IFFT in an OFDM modulator. Code for this IFFT has been written as a C++
2750 template class, and integrated as an Octave Oct-file. This allowed a
2751 single version of the code to be instantiated to perform both the fixed
2752 and floating point implementations of the same code. The instantiations
2755 template Fft<double,Complex,ComplexRowVector>;
2756 template Fft<FixedPoint,FixedPointComplex,FixedComplexRowVector>;
2758 template Ifft<double,Complex,ComplexRowVector>;
2759 template Ifft<FixedPoint,FixedPointComplex,FixedComplexRowVector>;
2761 The code for this example is available as part of the release of this
2764 A particular problem of a hardware implementation of an IFFT is that
2765 each butterfly in the radix-4 IFFT consists of the summation of four
2766 terms with a suitable phase. Thus, an additional 2 output bits are
2767 potentially needed after each butterfly of the radix-4 IFFT. There are
2768 several ways of addressing this issue
2770 1. Increase the number of bits in the fixed point representation by
2771 two after each radix-4 butterfly. There are then two ways of
2772 treating these added bits:
2774 A. Accept them and let the size of the representation of the
2775 fixed point numbers grows. For large IFFT's this is not
2778 B. Cut the least significant bits of representation, either
2779 after each butterfly, or after groups of butterflies. This
2780 reduces the number of bits in the representation, but still
2781 trades off complexity to avoid an overflow condition
2783 2. Keep the fixed point representation used in the IFFT fixed, but
2784 reduce the input signal level to avoid overflows. The IFFT can
2785 then have internal overflows.
2787 An overflow will cause a bit-error which is not necessarily
2788 critical. The last option is therefore attractive in that it allows the
2789 minimum complexity in the hardware implementation of the IFFT. However,
2790 careful investigation of the overflow effects are needed, which can be
2791 performed with the fixed point toolbox.
2793 The table below shows the case of a 64QAM OFDM signal similar to that
2794 used in the 802.11a standard. In this table the OFDM modulator has been
2795 represented using fixed point, while the rest of the system is assumed
2796 to be perfect. The table shows the tradeoff between the backoff of the
2797 RMS power in the frequency domain signal relative to the fixed point
2798 representation for several different fixed point representations.
2801 dB 8+1 Bits 10+1 Bits 12+1 Bits
2802 ------ ------- -------- --------
2803 5.00 2.11e-01 2.27e-01 2.30e-01
2804 6.00 1.09e-01 1.18e-01 1.21e-01
2805 7.00 4.23e-02 5.25e-02 5.53e-02
2806 8.00 1.17e-02 1.36e-02 1.48e-02
2807 9.00 5.34e-03 2.21e-03 2.33e-03
2808 10.00 7.49e-03 3.78e-04 3.71e-04
2809 11.00 1.22e-02 0.00e+00 0.00e+00
2810 12.00 2.00e-02 0.00e+00 0.00e+00
2811 13.00 3.12e-02 0.00e+00 0.00e+00
2812 14.00 4.34e-02 0.00e+00 0.00e+00
2813 15.00 6.12e-02 2.31e-07 0.00e+00
2814 16.00 7.53e-02 2.31e-06 0.00e+00
2815 17.00 9.00e-02 1.87e-05 0.00e+00
2816 18.00 1.15e-01 5.56e-05 0.00e+00
2817 19.00 1.30e-01 4.69e-04 0.00e+00
2818 20.00 1.55e-01 1.30e-03 0.00e+00
2819 21.00 1.84e-01 2.96e-03 0.00e+00
2820 22.00 1.98e-01 7.41e-03 0.00e+00
2821 23.00 2.30e-01 1.09e-02 0.00e+00
2822 24.00 2.50e-01 1.99e-02 0.00e+00
2823 25.00 2.73e-01 2.99e-02 0.00e+00
2824 26.00 2.99e-01 4.38e-02 0.00e+00
2825 27.00 3.39e-01 6.09e-02 2.31e-07
2826 28.00 3.51e-01 7.57e-02 2.31e-06
2827 29.00 3.86e-01 8.99e-02 9.72e-06
2828 30.00 3.97e-01 1.16e-01 6.99e-05
2830 Two regions are clearly visible in this table. When the backoff of
2831 the RMS power is small, the effects of the overflow in the IFFT
2832 dominate, and reduce the performance. When the backoff is large, there
2833 are fewer bits in the fixed point representation relative to the
2834 average signal power and therefore a slow degradation in the
2835 performance. It is clear that somewhere between 11 and 13 bits in the
2836 representation of the fixed point numbers in the IFFT is optimal, with a
2837 backoff of approximately 13dB.
2840 File: fixed.info, Node: Function Reference, Prev: Example, Up: Top
2842 4 Function Reference
2843 ********************
2847 * concat:: Concatenate two matrices regardless of their type.
2848 * create_lookup_table:: Creates a lookup table betwen the vectors X and Y.
2849 * display_fixed_operations:: Displays out a summary of the number of fixed
2850 point operations of each type that have been used.
2851 * fabs:: Compute the magnitude of the fixed point value X.
2852 * fangle:: See "farg".
2853 * farg:: Compute the argument of X, defined as THETA = `atan2 (Y,
2855 * fatan2:: Compute atan (Y / X) for corresponding fixed point elements
2857 * fceil:: Return the smallest integer not less than X.
2858 * fconj:: Returns the conjuate of the fixed point value X.
2859 * fcos:: Compute the cosine of the fixed point value X.
2860 * fcosh:: Compute the hyperbolic cosine of the fixed point value X.
2861 * fcumprod:: Cumulative product of elements along dimension DIM.
2862 * fcumsum:: Cumulative sum of elements along dimension DIM.
2863 * fdiag:: Return a diagonal matrix with fixed point vector V on
2865 * fexp:: Compute the exponential of the fixed point value X.
2866 * ffft:: Radix-4 fft in floating and fixed point for vectors of
2867 length 4^N, where N is an integer.
2868 * ffloor:: Return the largest integer not greater than X.
2869 * fifft:: Radix-4 ifft in fixed point for vectors of length 4^N,
2871 * fimag:: Returns the imaginary part of the fixed point value X.
2872 * fixed:: Used the create a fixed point variable.
2873 * fixed_inc:: Example code of the use of the fixed point types in an
2875 * fixed_point_count_operations:: Query or set the internal variable
2876 `fixed_point_count_operations'.
2877 * fixed_point_debug:: Query or set the internal variable
2878 `fixed_point_debug'.
2879 * fixed_point_library_version:: A function returning the version number of
2880 the fixed point library used.
2881 * fixed_point_version:: A function returning the version number of the
2882 fixed point package used.
2883 * fixed_point_warn_overflow:: Query or set the internal variable
2884 `fixed_point_warn_overflow'.
2885 * fixedpoint:: Manual and test code for the Octave Fixed Point toolbox.
2886 * float:: Converts a fixed point object to the equivalent floating
2888 * flog:: Compute the natural logarithm of the fixed point value X.
2889 * flog10:: Compute the base-10 logarithm of the fixed point value X.
2890 * fprod:: Product of elements along dimension DIM.
2891 * freal:: Returns the real part of the fixed point value X.
2892 * freshape:: Return a fixed matrix with M rows and N columns whose
2893 elements are taken from the fixed matrix A.
2894 * fround:: Return the rounded value to the nearest integer of X.
2895 * fsin:: Compute the sine of the fixed point value X.
2896 * fsinh:: Compute the hyperbolic sine of the fixed point value X.
2897 * fsort:: Return a copy of the fixed point variable X with the
2898 elements arranged in increasing order.
2899 * fsqrt:: Compute the square-root of the fixed point value X.
2900 * fsum:: Sum of elements along dimension DIM.
2901 * fsumsq:: Sum of squares of elements along dimension DIM.
2902 * ftan:: Compute the tan of the fixed point value X.
2903 * ftanh:: Compute the hyperbolic tan of the fixed point value X.
2904 * isfixed:: Return 1 if the value of the expression EXPR is a fixed
2906 * lookup_table:: Using the lookup table created by "create_lookup_table",
2907 find the value Y corresponding to X.
2908 * reset_fixed_operations:: Reset the count of fixed point operations to
2912 File: fixed.info, Node: concat, Next: create_lookup_table, Up: Function Reference
2917 -- Function File: X = concat (A, B)
2918 -- Function File: X = concat (A, B, DIM)
2919 Concatenate two matrices regardless of their type. Due to the
2920 implementation of the matrix concatenation in Octave being
2921 hard-coded for the types it knowns, user types can not use the
2922 matrix concatenation operator. Thus for the _Galois_ and _Fixed
2923 Point_ types, the in-built matrix concatenation functions will
2924 return a matrix value as their solution
2926 This function allows these types to be concatenated. If called
2927 with a user type that is not known by this function, the in-built
2928 concatenate function is used
2930 If DIM is 1, then the matrices are concatenated, else if DIM is 2,
2934 File: fixed.info, Node: create_lookup_table, Next: display_fixed_operations, Prev: concat, Up: Function Reference
2936 4.0.2 create_lookup_table
2937 -------------------------
2939 -- Function File: TABLE = create_lookup_table (X, Y)
2940 Creates a lookup table betwen the vectors X and Y. If X is not in
2941 increasing order, the vectors are sorted before being stored
2944 File: fixed.info, Node: display_fixed_operations, Next: fabs, Prev: create_lookup_table, Up: Function Reference
2946 4.0.3 display_fixed_operations
2947 ------------------------------
2949 -- Loadable Function: display_fixed_operations ( )
2950 Displays out a summary of the number of fixed point operations of
2951 each type that have been used. This can be used to give a estimate
2952 of the complexity of an algorithm.
2953 See also: fixed_point_count_operations, reset_fixed_operations
2956 File: fixed.info, Node: fabs, Next: fangle, Prev: display_fixed_operations, Up: Function Reference
2961 -- Loadable Function: Y = fabs (X)
2962 Compute the magnitude of the fixed point value X.
2965 File: fixed.info, Node: fangle, Next: farg, Prev: fabs, Up: Function Reference
2970 -- Loadable Function: Y = fangle (X)
2974 File: fixed.info, Node: farg, Next: fatan2, Prev: fangle, Up: Function Reference
2979 -- Loadable Function: Y = farg (X)
2980 Compute the argument of X, defined as THETA = `atan2 (Y, X)' in
2981 radians. For example
2983 farg (fixed (3,5,3+4i))
2987 File: fixed.info, Node: fatan2, Next: fceil, Prev: farg, Up: Function Reference
2992 -- Loadable Function: fatan2 (Y, X)
2993 Compute atan (Y / X) for corresponding fixed point elements of Y
2994 and X. The result is in range -pi to pi.
2997 File: fixed.info, Node: fceil, Next: fconj, Prev: fatan2, Up: Function Reference
3002 -- Loadable Function: Y = fceil (X)
3003 Return the smallest integer not less than X.
3004 See also: fround, ffloor
3007 File: fixed.info, Node: fconj, Next: fcos, Prev: fceil, Up: Function Reference
3012 -- Loadable Function: Y = fconj (X)
3013 Returns the conjuate of the fixed point value X.
3016 File: fixed.info, Node: fcos, Next: fcosh, Prev: fconj, Up: Function Reference
3021 -- Loadable Function: Y = fcos (X)
3022 Compute the cosine of the fixed point value X.
3023 See also: fcosh, fsin, fsinh, ftan, ftanh
3026 File: fixed.info, Node: fcosh, Next: fcumprod, Prev: fcos, Up: Function Reference
3031 -- Loadable Function: Y = fcosh (X)
3032 Compute the hyperbolic cosine of the fixed point value X.
3033 See also: fcos, fsin, fsinh, ftan, ftanh
3036 File: fixed.info, Node: fcumprod, Next: fcumsum, Prev: fcosh, Up: Function Reference
3041 -- Loadable Function: Y = fcumprod (X,DIM)
3042 Cumulative product of elements along dimension DIM. If DIM is
3043 omitted, it defaults to 1 (column-wise cumulative products).
3047 File: fixed.info, Node: fcumsum, Next: fdiag, Prev: fcumprod, Up: Function Reference
3052 -- Loadable Function: Y = fcumsum (X,DIM)
3053 Cumulative sum of elements along dimension DIM. If DIM is
3054 omitted, it defaults to 1 (column-wise cumulative sums).
3058 File: fixed.info, Node: fdiag, Next: fexp, Prev: fcumsum, Up: Function Reference
3063 -- Loadable Function: fdiag (V, K)
3064 Return a diagonal matrix with fixed point vector V on diagonal K.
3065 The second argument is optional. If it is positive, the vector is
3066 placed on the K-th super-diagonal. If it is negative, it is placed
3067 on the -K-th sub-diagonal. The default value of K is 0, and the
3068 vector is placed on the main diagonal. For example,
3070 fdiag (fixed(3,2,[1, 2, 3]), 1)
3078 Note that if all of the elements of the original vector have the
3079 same fixed point representation, then the zero elements in the
3080 matrix are created with the same representation. Otherwise the
3081 zero elements are created with the equivalent of the fixed point
3082 value `fixed(0,0,0)'.n
3086 File: fixed.info, Node: fexp, Next: ffft, Prev: fdiag, Up: Function Reference
3091 -- Loadable Function: Y = fexp (X)
3092 Compute the exponential of the fixed point value X.
3093 See also: log, log10, pow
3096 File: fixed.info, Node: ffft, Next: ffloor, Prev: fexp, Up: Function Reference
3101 -- Loadable Function: Y = ffft (X)
3102 Radix-4 fft in floating and fixed point for vectors of length 4^N,
3103 where N is an integer. The variable X can be a either a row of
3104 column vector, in which case a single fft is carried out over the
3105 vector of length 4^N. If X is a matrix, the fft is carried on each
3106 column of X and the matrix must contain 4^N rows.
3108 The radix-4 fft is implemented in a manner that attempts to
3109 approximate how it will be implemented in hardware, rather than
3110 use a generic butterfly. The radix-4 algorithm is faster and more
3111 precise than the equivalent radix-2 algorithm, and thus is
3112 preferred for hardware implementation. See also: fifft
3115 File: fixed.info, Node: ffloor, Next: fifft, Prev: ffft, Up: Function Reference
3120 -- Loadable Function: Y = ffloor (X)
3121 Return the largest integer not greater than X.
3122 See also: fround, fceil
3125 File: fixed.info, Node: fifft, Next: fimag, Prev: ffloor, Up: Function Reference
3130 -- Loadable Function: Y = fifft (X)
3131 Radix-4 ifft in fixed point for vectors of length 4^N, where. N
3132 is an integer. The variable X can be a either a row of column
3133 vector, in which case a single ifft is carried out over the vector
3134 of length 4^N. If X is a matrix, the ifft is carried on each
3135 column of X and the matrix must contain 4^N rows.
3137 The radix-4 ifft is implemented in a manner that attempts to
3138 approximate how it will be implemented in hardware, rather than
3139 use a generic butterfly. The radix-4 algorithm is faster and more
3140 precise than the equivalent radix-2 algorithm, and thus is
3141 preferred for hardware implementation. See also: ffft
3144 File: fixed.info, Node: fimag, Next: fixed, Prev: fifft, Up: Function Reference
3149 -- Loadable Function: Y = fimag (X)
3150 Returns the imaginary part of the fixed point value X.
3153 File: fixed.info, Node: fixed, Next: fixed_inc, Prev: fimag, Up: Function Reference
3158 -- Loadable Function: Y = fixed (F)
3159 -- Loadable Function: Y = fixed (IS,DS)
3160 -- Loadable Function: Y = fixed (IS,DS,F)
3161 Used the create a fixed point variable. Called with a single
3162 argument, if F is itself a fixed point value, then "fixed" is
3163 equivalent to `Y = F'. Otherwise the integer part of F is used to
3164 create a fixed point variable with the minimum number of bits
3165 needed to represent it. F can be either real of complex.
3167 Called with two or more arguments IS represents the number of bits
3168 used to represent the integer part of the fixed point numbers, and
3169 DS the number used to represent the decimal part. These variables
3170 must be either positive integer scalars or matrices. If they are
3171 matrices they must be of the same dimension, and each fixed point
3172 number in the created matrix will have the representation given by
3173 the corresponding values of IS and DS.
3175 When creating complex fixed point values, the fixed point
3176 representation can be different for the real and imaginary parts.
3177 In this case IS and DS are complex integers. Additionally the
3178 maximum value of the sum of IS and DS is limited by the
3179 representation of long integers to either 30 or 62.
3181 Called with only two arguments, the fixed point variable that is
3182 created will contain only zeros. A third argument can be used to
3183 give the values of the fixed variables elements. This third
3184 argument F can be either a fixed point variable itself, which
3185 results in a new fixed point variable being created with a
3186 different representation, or a real or complex matrix.
3189 File: fixed.info, Node: fixed_inc, Next: fixed_point_count_operations, Prev: fixed, Up: Function Reference
3194 -- Loadable Function: Y = fixed_inc (X)
3195 Example code of the use of the fixed point types in an oct-file.
3199 File: fixed.info, Node: fixed_point_count_operations, Next: fixed_point_debug, Prev: fixed_inc, Up: Function Reference
3201 4.0.22 fixed_point_count_operations
3202 -----------------------------------
3204 -- Loadable Function: VAL = fixed_point_count_operations ()
3205 -- Loadable Function: OLD_VAL = fixed_point_count_operations (NEW_VAL)
3206 Query or set the internal variable `fixed_point_count_operations'.
3207 If enabled, Octave keeps track of how many times each type of
3208 floating point operation has been used internally. This can be
3209 used to give an approximation of the algorithms complexity. By
3210 default, this feature is disabled. See also:
3211 display_fixed_operations
3214 File: fixed.info, Node: fixed_point_debug, Next: fixed_point_library_version, Prev: fixed_point_count_operations, Up: Function Reference
3216 4.0.23 fixed_point_debug
3217 ------------------------
3219 -- Loadable Function: VAL = fixed_point_debug ()
3220 -- Loadable Function: OLD_VAL = fixed_point_debug (NEW_VAL)
3221 Query or set the internal variable `fixed_point_debug'. If
3222 enabled, Octave keeps a copy of the value of fixed point variable
3223 internally. This is useful for use with a debug to allow easy
3224 access to the variables value. By default this feature is
3228 File: fixed.info, Node: fixed_point_library_version, Next: fixed_point_version, Prev: fixed_point_debug, Up: Function Reference
3230 4.0.24 fixed_point_library_version
3231 ----------------------------------
3233 -- Loadable Function: fixed_point_library_version ()
3234 A function returning the version number of the fixed point library
3238 File: fixed.info, Node: fixed_point_version, Next: fixed_point_warn_overflow, Prev: fixed_point_library_version, Up: Function Reference
3240 4.0.25 fixed_point_version
3241 --------------------------
3243 -- Loadable Function: fixed_point_version ()
3244 A function returning the version number of the fixed point package
3248 File: fixed.info, Node: fixed_point_warn_overflow, Next: fixedpoint, Prev: fixed_point_version, Up: Function Reference
3250 4.0.26 fixed_point_warn_overflow
3251 --------------------------------
3253 -- Loadable Function: VAL = fixed_point_warn_overflow ()
3254 -- Loadable Function: OLD_VAL = fixed_point_warn_overflow (NEW_VAL)
3255 Query or set the internal variable `fixed_point_warn_overflow'.
3256 If enabled, Octave warns of overflows in fixed point operations.
3257 By default, these warnings are disabled.
3260 File: fixed.info, Node: fixedpoint, Next: float, Prev: fixed_point_warn_overflow, Up: Function Reference
3265 -- Function File: fixedpoint ('help')
3266 -- Function File: fixedpoint ('info')
3267 -- Function File: fixedpoint ('info', MOD)
3268 -- Function File: fixedpoint ('test')
3269 -- Function File: fixedpoint ('test', MOD)
3270 Manual and test code for the Octave Fixed Point toolbox. There are
3271 5 possible ways to call this function
3273 `fixedpoint ('help')'
3274 Display this help message. Called with no arguments, this
3275 function also displays this help message
3277 `fixedpoint ('info')'
3278 Open the Fixed Point toolbox manual
3280 `fixedpoint ('info', MOD)'
3281 Open the Fixed Point toolbox manual at the section specified
3284 `fixedpoint ('test')'
3285 Run all of the test code for the Fixed Point toolbox MOD
3287 Valid values for the varibale MOD are
3290 The section describing the use of the fixed point toolbox
3294 The section descrining how to use the fixed-point type with
3298 The section describing an in-depth example of the use of the
3302 The refernce section of all of the specific fixed point
3303 operators and functions
3305 Please note that this function file should be used as an example
3306 of the use of this toolbox
3309 File: fixed.info, Node: float, Next: flog, Prev: fixedpoint, Up: Function Reference
3314 -- Function File: Y = float (X)
3315 Converts a fixed point object to the equivalent floating point
3316 object. This is equivalent to `X.x' if `isfixed(X)' returns true,
3317 and returns X otherwise
3320 File: fixed.info, Node: flog, Next: flog10, Prev: float, Up: Function Reference
3325 -- Loadable Function: Y = flog (X)
3326 Compute the natural logarithm of the fixed point value X.
3327 See also: fexp, flog10, fpow
3330 File: fixed.info, Node: flog10, Next: fprod, Prev: flog, Up: Function Reference
3335 -- Loadable Function: Y = flog10 (X)
3336 Compute the base-10 logarithm of the fixed point value X.
3337 See also: fexp, flog, fpow
3340 File: fixed.info, Node: fprod, Next: freal, Prev: flog10, Up: Function Reference
3345 -- Loadable Function: Y = fprod (X,DIM)
3346 Product of elements along dimension DIM. If DIM is omitted, it
3347 defaults to 1 (column-wise products).
3348 See also: fsum, fsumsq
3351 File: fixed.info, Node: freal, Next: freshape, Prev: fprod, Up: Function Reference
3356 -- Loadable Function: Y = freal (X)
3357 Returns the real part of the fixed point value X.
3360 File: fixed.info, Node: freshape, Next: fround, Prev: freal, Up: Function Reference
3365 -- Loadable Function: freshape (A, M, N)
3366 Return a fixed matrix with M rows and N columns whose elements are
3367 taken from the fixed matrix A. To decide how to order the
3368 elements, Octave pretends that the elements of a matrix are stored
3369 in column-major order (like Fortran arrays are stored).
3373 freshape (fixed(3, 2, [1, 2, 3, 4]), 2, 2)
3379 If the variable `do_fortran_indexing' is nonzero, the `freshape'
3380 function is equivalent to
3382 retval = fixed(0,0,zeros (m, n));
3385 but it is somewhat less cryptic to use `freshape' instead of the
3386 colon operator. Note that the total number of elements in the
3387 original matrix must match the total number of elements in the new
3389 See also: `:' and do_fortran_indexing
3392 File: fixed.info, Node: fround, Next: fsin, Prev: freshape, Up: Function Reference
3397 -- Loadable Function: Y = fround (X)
3398 Return the rounded value to the nearest integer of X.
3399 See also: ffloor, fceil
3402 File: fixed.info, Node: fsin, Next: fsinh, Prev: fround, Up: Function Reference
3407 -- Loadable Function: Y = fsin (X)
3408 Compute the sine of the fixed point value X.
3409 See also: fcos, fcosh, fsinh, ftan, ftanh
3412 File: fixed.info, Node: fsinh, Next: fsort, Prev: fsin, Up: Function Reference
3417 -- Loadable Function: Y = fsinh (X)
3418 Compute the hyperbolic sine of the fixed point value X.
3419 See also: fcos, fcosh, fsin, ftan, ftanh
3422 File: fixed.info, Node: fsort, Next: fsqrt, Prev: fsinh, Up: Function Reference
3427 -- Function File: [S, I] = fsort (X)
3428 Return a copy of the fixed point variable X with the elements
3429 arranged in increasing order. For matrices, `fsort' orders the
3430 elements in each column
3434 fsort (fixed(4,0,[1, 2; 2, 3; 3, 1]))
3439 The `fsort' function may also be used to produce a matrix
3440 containing the original row indices of the elements in the sorted
3441 matrix. For example,
3443 [s, i] = sort ([1, 2; 2, 3; 3, 1])
3452 File: fixed.info, Node: fsqrt, Next: fsum, Prev: fsort, Up: Function Reference
3457 -- Loadable Function: Y = fsqrt (X)
3458 Compute the square-root of the fixed point value X.
3461 File: fixed.info, Node: fsum, Next: fsumsq, Prev: fsqrt, Up: Function Reference
3466 -- Loadable Function: Y = fsum (X,DIM)
3467 Sum of elements along dimension DIM. If DIM is omitted, it
3468 defaults to 1 (column-wise sum).
3469 See also: fprod, fsumsq
3472 File: fixed.info, Node: fsumsq, Next: ftan, Prev: fsum, Up: Function Reference
3477 -- Loadable Function: Y = fsumsq (X,DIM)
3478 Sum of squares of elements along dimension DIM. If DIM is
3479 omitted, it defaults to 1 (column-wise sum of squares). This
3480 function is equivalent to computing
3481 fsum (x .* fconj (x), dim)
3482 but it uses less memory and avoids calling `fconj' if X is real.
3483 See also: fprod, fsum
3486 File: fixed.info, Node: ftan, Next: ftanh, Prev: fsumsq, Up: Function Reference
3491 -- Loadable Function: Y = ftan (X)
3492 Compute the tan of the fixed point value X.
3493 See also: fcos, fcosh, fsinh, ftan, ftanh
3496 File: fixed.info, Node: ftanh, Next: isfixed, Prev: ftan, Up: Function Reference
3501 -- Loadable Function: Y = ftanh (X)
3502 Compute the hyperbolic tan of the fixed point value X.
3503 See also: fcos, fcosh, fsin, fsinh, ftan
3506 File: fixed.info, Node: isfixed, Next: lookup_table, Prev: ftanh, Up: Function Reference
3511 -- Loadable Function: isfixed (EXPR)
3512 Return 1 if the value of the expression EXPR is a fixed point
3516 File: fixed.info, Node: lookup_table, Next: reset_fixed_operations, Prev: isfixed, Up: Function Reference
3521 -- Function File: Y = lookup_table (TABLE, X)
3522 -- Function File: Y = lookup_table (TABLE, X, INTERP, EXTRAP)
3523 Using the lookup table created by "create_lookup_table", find the
3524 value Y corresponding to X. With two arguments the lookup is done
3525 to the nearest value below in the table less than the desired
3526 value. With three arguments a simple linear interpolation is
3527 performed. With four arguments an extrapolation is also performed.
3528 The exact values of arguments three and four are irrelevant, as
3529 only there presence detremines whether interpolation and/or
3530 extrapolation are used
3533 File: fixed.info, Node: reset_fixed_operations, Prev: lookup_table, Up: Function Reference
3535 4.0.45 reset_fixed_operations
3536 -----------------------------
3538 -- Loadable Function: reset_fixed_operations ( )
3539 Reset the count of fixed point operations to zero.
3540 See also: fixed_point_count_operations, display_fixed_operations
3547 Node: License
\7f2189
3548 Node: Representation
\7f3637
3549 Node: Creation
\7f5758
3550 Node: Overflow
\7f10324
3551 Node: Built-in Variables
\7f12463
3552 Node: Accessing Internal Fields
\7f15016
3553 Node: Function Overloading
\7f17290
3554 Node: Together
\7f19419
3555 Node: Precision
\7f21133
3556 Node: Lookup Tables
\7f22801
3557 Node: Known Problems
\7f24895
3558 Node: Programming
\7f30612
3559 Node: FixedPoint
\7f32047
3560 Node: FPConstructors
\7f32393
3561 Node: FPSpecific
\7f34500
3562 Node: FPOperators
\7f38437
3563 Node: FPFunctions
\7f42058
3564 Node: FixedPointComplex
\7f44635
3565 Node: FPCConstructors
\7f45488
3566 Node: FPCSpecific
\7f53798
3567 Node: FPCOperators
\7f59333
3568 Node: FPCFunctions
\7f61802
3569 Node: Derived
\7f65276
3570 Node: FixedMatrix
\7f67221
3571 Node: FixedRowVector
\7f73874
3572 Node: FixedColumnVector
\7f80858
3573 Node: FixedComplexMatrix
\7f88161
3574 Node: FixedComplexRowVector
\7f99293
3575 Node: FixedComplexColumnVector
\7f111035
3576 Node: Upper
\7f123337
3577 Node: Oct-files
\7f125003
3578 Node: Templates
\7f125932
3579 Node: Problems
\7f127400
3580 Node: Cygwin
\7f129334
3581 Node: OctExample
\7f130559
3582 Node: Example
\7f133601
3583 Node: Function Reference
\7f138734
3584 Node: concat
\7f142156
3585 Node: create_lookup_table
\7f143001
3586 Node: display_fixed_operations
\7f143367
3588 Node: fangle
\7f144070
3590 Node: fatan2
\7f144545
3591 Node: fceil
\7f144815
3592 Node: fconj
\7f145041
3594 Node: fcosh
\7f145486
3595 Node: fcumprod
\7f145744
3596 Node: fcumsum
\7f146066
3597 Node: fdiag
\7f146378
3600 Node: ffloor
\7f148441
3601 Node: fifft
\7f148672
3602 Node: fimag
\7f149487
3603 Node: fixed
\7f149699
3604 Node: fixed_inc
\7f151463
3605 Node: fixed_point_count_operations
\7f151745
3606 Node: fixed_point_debug
\7f152436
3607 Node: fixed_point_library_version
\7f153025
3608 Node: fixed_point_version
\7f153370
3609 Node: fixed_point_warn_overflow
\7f153699
3610 Node: fixedpoint
\7f154205
3611 Node: float
\7f155705
3613 Node: flog10
\7f156266
3614 Node: fprod
\7f156511
3615 Node: freal
\7f156803
3616 Node: freshape
\7f157013
3617 Node: fround
\7f158021
3619 Node: fsinh
\7f158503
3620 Node: fsort
\7f158756
3621 Node: fsqrt
\7f159503
3623 Node: fsumsq
\7f159991
3625 Node: ftanh
\7f160690
3626 Node: isfixed
\7f160944
3627 Node: lookup_table
\7f161190
3628 Node: reset_fixed_operations
\7f161964