Debian Codegraph @

3rdparty/dissection/src/Compiler/arithmetic.cpp

raw
1 /*! \file arithmetic.cpp
2 \brief higher precision arithmetic for Kernel Detection
3 \author Atsushi Suzuki, Laboratoire Jacques-Louis Lions
4 \date Jul. 17th 2015
5 \date Feb. 29th 2016
6 \date Nov. 30th 2016
7 */
8
9 // This file is part of Dissection
10 //
11 // Dissection is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // Linking Dissection statically or dynamically with other modules is making
17 // a combined work based on Disssection. Thus, the terms and conditions of
18 // the GNU General Public License cover the whole combination.
19 //
20 // As a special exception, the copyright holders of Dissection give you
21 // permission to combine Dissection program with free software programs or
22 // libraries that are released under the GNU LGPL and with independent modules
23 // that communicate with Dissection solely through the Dissection-fortran
24 // interface. You may copy and distribute such a system following the terms of
25 // the GNU GPL for Dissection and the licenses of the other code concerned,
26 // provided that you include the source code of that other code when and as
27 // the GNU GPL requires distribution of source code and provided that you do
28 // not modify the Dissection-fortran interface.
29 //
30 // Note that people who make modified versions of Dissection are not obligated
31 // to grant this special exception for their modified versions; it is their
32 // choice whether to do so. The GNU General Public License gives permission to
33 // release a modified version without this exception; this exception also makes
34 // it possible to release a modified version which carries forward this
35 // exception. If you modify the Dissection-fortran interface, this exception
36 // does not apply to your modified version of Dissection, and you must remove
37 // this exception when you distribute your modified version.
38 //
39 // This exception is an additional permission under section 7 of the GNU
40 // General Public License, version 3 ("GPLv3")
41 //
42 // Dissection is distributed in the hope that it will be useful,
43 // but WITHOUT ANY WARRANTY; without even the implied warranty of
44 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 // GNU General Public License for more details.
46 //
47 // You should have received a copy of the GNU General Public License
48 // along with Dissection. If not, see <http://www.gnu.org/licenses/>.
49 //
50
51 #include <cstdio>
52 #include "Compiler/arithmetic.hpp"
53 #include "Compiler/blas.hpp"
54
55 template<>
56 void printscalar<double>(const bool verbose, FILE *fp, double x)
57 {
58 if (verbose && (fp != NULL)) {
59 fprintf(fp, "%16.8e ", x);
60 }
61 }
62
63 template<>
64 void printscalar<float>(const bool verbose, FILE *fp, float x)
65 {
66 if (verbose && (fp != NULL)) {
67 fprintf(fp, "%16.8e ", x);
68 }
69 }
70
71 template<>
72 void printscalar<quadruple>(const bool verbose, FILE *fp, quadruple x)
73 {
74 if (verbose && (fp != NULL)) {
75 fprintf(fp, "%16.8e ", quad2double(x));
76 }
77 }
78
79 template<>
80 void printscalar<complex<double> >(const bool verbose, FILE *fp,
81 complex<double> x)
82 {
83 if (verbose && (fp != NULL)) {
84 fprintf(fp, "(%16.8e %16.8e) ", x.real(), x.imag());
85 }
86 }
87
88 template<>
89 void printscalar<complex<float> >(const bool verbose, FILE *fp,
90 complex<float> x)
91 {
92 if (verbose && (fp != NULL)) {
93 fprintf(fp, "(%16.8e %16.8e) ", x.real(), x.imag());
94 }
95 }
96
97 template<>
98 void printscalar<complex<quadruple> >(const bool verbose, FILE *fp,
99 complex<quadruple> x)
100 {
101 if (verbose && (fp != NULL)) {
102 fprintf(fp, "(%16.8e %16.8e) ",
103 quad2double(x.real()), quad2double(x.imag()));
104 }
105 }
106
107 template<typename T>
108 void printscalar(const bool verbose, FILE *fp, T x)
109 {
110 fprintf(stderr, "%s %d : printscalar is not implented\n",
111 __FILE__, __LINE__);
112 }
113 #ifndef NO_OCTRUPLE
114 template
115 void printscalar<octruple>(const bool verbose, FILE *fp, octruple x);
116 template
117 void printscalar<complex<octruple> >(const bool verbose,
118 FILE *fp, complex<octruple> x);
119 #endif
120