GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
DET.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2008-2018 Jaroslav Hajek
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_DET_h)
24 #define octave_DET_h 1
25 
26 #include "octave-config.h"
27 
28 #include <cmath>
29 
30 #include "lo-mappers.h"
31 #include "oct-cmplx.h"
32 
33 template <typename T>
34 class
36 {
37 public:
38 
39  base_det (T c = 1, int e = 0)
40  : c2 (), e2 ()
41  {
42  c2 = octave::math::log2 (c, e2);
43  e2 += e;
44  }
45 
46  base_det (T c, double e, double b)
47  : c2 (), e2 ()
48  {
49  e *= octave::math::log2 (b);
50  e2 = e;
51  c *= octave::math::exp2 (e - e2);
52  int f;
53  c2 = octave::math::log2 (c, f);
54  e2 += f;
55  }
56 
57  base_det (const base_det& a) : c2 (a.c2), e2 (a.e2) { }
58 
60  {
61  c2 = a.c2;
62  e2 = a.e2;
63  return *this;
64  }
65 
66  T coef (void) const { return c2; }
67  int exp (void) const { return e2; }
68 
69  T value () const { return c2 * static_cast<T> (std::ldexp (1.0, e2)); }
70  operator T () const { return value (); }
71 
72  base_det square () const { return base_det (c2*c2, e2+e2); }
73 
74  void operator *= (T t)
75  {
76  int e;
77  c2 *= t;
78  // Renormalize c2 to [0.5, 1), and find required change in exponent.
79  c2 = octave::math::log2 (c2, e);
80  e2 += e;
81  }
82 
83 private:
84 
85  T c2;
86  int e2;
87 };
88 
89 // Provide the old types by typedefs.
94 
95 #endif
T value() const
Definition: DET.h:69
base_det< double > DET
Definition: DET.h:90
base_det< FloatComplex > FloatComplexDET
Definition: DET.h:93
int e2
Definition: DET.h:86
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
NDArray & operator=(const NDArray &a)
Definition: dNDArray.h:69
base_det(const base_det &a)
Definition: DET.h:57
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
i e
Definition: data.cc:2591
Complex log2(const Complex &x)
Definition: lo-mappers.cc:137
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
base_det< float > FloatDET
Definition: DET.h:91
T c2
Definition: DET.h:85
base_det(T c=1, int e=0)
Definition: DET.h:39
ComplexColumnVector operator*=(ComplexColumnVector &x, const Complex &y)
Definition: CColVector.h:150
Definition: DET.h:34
T coef(void) const
Definition: DET.h:66
double exp2(double x)
Definition: lo-mappers.h:107
base_det square() const
Definition: DET.h:72
int exp(void) const
Definition: DET.h:67
b
Definition: cellfun.cc:400
base_det< Complex > ComplexDET
Definition: DET.h:92
base_det(T c, double e, double b)
Definition: DET.h:46
nd group nd example For each display the value
Definition: sysdep.cc:866