ergo
template_lapack_ladiv.h
Go to the documentation of this file.
1
/* Ergo, version 3.8, a program for linear scaling electronic structure
2
* calculations.
3
* Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4
* and Anastasia Kruchinina.
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*
19
* Primary academic reference:
20
* Ergo: An open-source program for linear-scaling electronic structure
21
* calculations,
22
* Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23
* Kruchinina,
24
* SoftwareX 7, 107 (2018),
25
* <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26
*
27
* For further information about Ergo, see <http://www.ergoscf.org>.
28
*/
29
30
/* This file belongs to the template_lapack part of the Ergo source
31
* code. The source files in the template_lapack directory are modified
32
* versions of files originally distributed as CLAPACK, see the
33
* Copyright/license notice in the file template_lapack/COPYING.
34
*/
35
36
37
#ifndef TEMPLATE_LAPACK_LADIV_HEADER
38
#define TEMPLATE_LAPACK_LADIV_HEADER
39
40
41
template
<
class
Treal>
42
int
template_lapack_ladiv
(
const
Treal *a,
const
Treal *b,
const
Treal *c__,
43
const
Treal *d__, Treal *p, Treal *q)
44
{
45
/* -- LAPACK auxiliary routine (version 3.0) --
46
Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
47
Courant Institute, Argonne National Lab, and Rice University
48
October 31, 1992
49
50
51
Purpose
52
=======
53
54
DLADIV performs complex division in real arithmetic
55
56
a + i*b
57
p + i*q = ---------
58
c + i*d
59
60
The algorithm is due to Robert L. Smith and can be found
61
in D. Knuth, The art of Computer Programming, Vol.2, p.195
62
63
Arguments
64
=========
65
66
A (input) DOUBLE PRECISION
67
B (input) DOUBLE PRECISION
68
C (input) DOUBLE PRECISION
69
D (input) DOUBLE PRECISION
70
The scalars a, b, c, and d in the above expression.
71
72
P (output) DOUBLE PRECISION
73
Q (output) DOUBLE PRECISION
74
The scalars p and q in the above expression.
75
76
===================================================================== */
77
Treal e, f;
78
79
80
81
if
(
absMACRO
(*d__) <
absMACRO
(*c__)) {
82
e = *d__ / *c__;
83
f = *c__ + *d__ * e;
84
*p = (*a + *b * e) / f;
85
*q = (*b - *a * e) / f;
86
}
else
{
87
e = *c__ / *d__;
88
f = *d__ + *c__ * e;
89
*p = (*b + *a * e) / f;
90
*q = (-(*a) + *b * e) / f;
91
}
92
93
return
0;
94
95
/* End of DLADIV */
96
97
}
/* dladiv_ */
98
99
#endif
absMACRO
#define absMACRO(x)
Definition:
template_blas_common.h:47
template_lapack_ladiv
int template_lapack_ladiv(const Treal *a, const Treal *b, const Treal *c__, const Treal *d__, Treal *p, Treal *q)
Definition:
template_lapack_ladiv.h:42
source
matrix
template_lapack
lapack
template_lapack_ladiv.h
Generated on Sun Aug 16 2020 00:00:00 for ergo by
1.8.18