1 // -*- C++ -*-
2 //
3 // Unoptimized reimplementation of vectorized mathematica functions
4 // from the IBM mass library.
5 //
6 // Copyright (C) 1996-2011 Jakob Schiotz and Center for Individual
7 // Nanoparticle Functionality, Department of Physics, Technical
8 // University of Denmark. Email: schiotz@fysik.dtu.dk
9 //
10 // This file is part of Asap version 3.
11 // Asap is released under the GNU Lesser Public License (LGPL) version 3.
12 // However, the parts of Asap distributed within the OpenKIM project
13 // (including this file) are also released under the Common Development
14 // and Distribution License (CDDL) version 1.0.
15 //
16 // This program is free software: you can redistribute it and/or
17 // modify it under the terms of the GNU Lesser General Public License
18 // version 3 as published by the Free Software Foundation. Permission
19 // to use other versions of the GNU Lesser General Public License may
20 // granted by Jakob Schiotz or the head of department of the
21 // Department of Physics, Technical University of Denmark, as
22 // described in section 14 of the GNU General Public License.
23 //
24 // This program is distributed in the hope that it will be useful,
25 // but WITHOUT ANY WARRANTY; without even the implied warranty of
26 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 // GNU General Public License for more details.
28 //
29 // You should have received a copy of the GNU General Public License
30 // and the GNU Lesser Public License along with this program. If not,
31 // see <http://www.gnu.org/licenses/>.
32
33
34
35 #include <math.h>
36
37 namespace ASAPSPACE {
38
vsqrt(double res[],const double a[],const int * n)39 inline void vsqrt(double res[], const double a[], const int *n)
40 {
41 int nn = *n;
42 for (int i = 0; i < nn; i++)
43 res[i] = sqrt(a[i]);
44 }
45
vexp(double res[],const double a[],const int * n)46 inline void vexp(double res[], const double a[], const int *n)
47 {
48 int nn = *n;
49 for (int i = 0; i < nn; i++)
50 res[i] = exp(a[i]);
51 }
52
vrec(double res[],const double a[],const int * n)53 inline void vrec(double res[], const double a[], const int *n)
54 {
55 int nn = *n;
56 for (int i = 0; i < nn; i++)
57 res[i] = 1.0 / a[i];
58 }
59
vlog(double res[],const double a[],const int * n)60 inline void vlog(double res[], const double a[], const int *n)
61 {
62 int nn = *n;
63 for (int i = 0; i < nn; i++)
64 res[i] = log(a[i]);
65 }
66
67 } // end namespace
68
69
70