summaryrefslogtreecommitdiff
path: root/src/elementaryFunctions/acosh/testAcosh.c
blob: 491867e3e00daf1899243c98b918eebc4c2e45a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 *  Copyright (C) 2006-2008 - INRIA - Bruno JOFRET
 *
 *  This file must be used under the terms of the CeCILL.
 *  This source file is licensed as described in the file COPYING, which
 *  you should have received as part of this distribution.  The terms
 *  are also available at
 *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 *
 */

#include "testAcosh.h"

void sacoshsTest(void) {
  printf(">> Float scalar\n");
  printf("sacoshs(0) = %f\n", sacoshs((float) 0));
  printf("sacoshs(PI) = %f\n", sacoshs(PI));
  printf("sacoshs(PI/2) = %f\n", sacoshs(PI/2));
  printf("sacoshs(PI/3) = %f\n", sacoshs(PI/3));
  printf("sacoshs(PI/4) = %f\n", sacoshs(PI/4));
  printf("sacoshs(PI/6) = %f\n", sacoshs(PI/6));
  printf("sacoshs(-PI) = %f\n", sacoshs(-PI));
  printf("sacoshs(-PI/2) = %f\n", sacoshs(-PI/2));
  printf("sacoshs(-PI/3) = %f\n", sacoshs(-PI/3));
  printf("sacoshs(-PI/4) = %f\n", sacoshs(-PI/4));
  printf("sacoshs(-PI/6) = %f\n", sacoshs(-PI/6));
}

void dacoshsTest(void) {
  printf(">> Double scalar\n");
  printf("dacoshs(0) = %e\n", dacoshs((double) 0));
  printf("dacoshs(PI) = %e\n", dacoshs(PI));
  printf("dacoshs(PI/2) = %e\n", dacoshs(PI/2));
  printf("dacoshs(PI/3) = %e\n", dacoshs(PI/3));
  printf("dacoshs(PI/4) = %e\n", dacoshs(PI/4));
  printf("dacoshs(PI/6) = %e\n", dacoshs(PI/6));
  printf("dacoshs(-PI) = %e\n", dacoshs(-PI));
  printf("dacoshs(-PI/2) = %e\n", dacoshs(-PI/2));
  printf("dacoshs(-PI/3) = %e\n", dacoshs(-PI/3));
  printf("dacoshs(-PI/4) = %e\n", dacoshs(-PI/4));
  printf("dacoshs(-PI/6) = %e\n", dacoshs(-PI/6));
}

void cacoshsTest(void) {
  floatComplex pi_pi = FloatComplex(PI, PI);
  floatComplex pi_2_pi_2 = FloatComplex(PI/2, PI/2);
  floatComplex pi_2_pi_3 = FloatComplex(PI/2, PI/3);
  floatComplex pi_2_pi_4 = FloatComplex(PI/2, PI/4);
  floatComplex out;

  printf(">> Float Complex scalar\n");
  out = cacoshs(pi_pi);
  printf("cacoshs(PI + I*PI) = %f + I * %f\n", creals(out), cimags(out));
  out = cacoshs(pi_2_pi_2);
  printf("cacoshs(PI/2 + I*PI/2) = %f + I * %f\n", creals(out), cimags(out));
  out = cacoshs(pi_2_pi_3);
  printf("cacoshs(PI/2 + I*PI/3) = %f + I * %f\n", creals(out), cimags(out));
  out = cacoshs(pi_2_pi_4);
  printf("cacoshs(PI/2 + I*PI/4) = %f + I * %f\n", creals(out), cimags(out));
}

void zacoshsTest(void) {
  doubleComplex pi_pi = DoubleComplex(PI, PI);
  doubleComplex pi_2_pi_2 = DoubleComplex(PI/2, PI/2);
  doubleComplex pi_2_pi_3 = DoubleComplex(PI/2, PI/3);
  doubleComplex pi_2_pi_4 = DoubleComplex(PI/2, PI/4);
  doubleComplex out;

  printf(">> Double Complex scalar\n");
  out = zacoshs(pi_pi);
  printf("zacoshs(PI + I*PI) = %e + I * %e\n", zreals(out), zimags(out));
  out = zacoshs(pi_2_pi_2);
  printf("zacoshs(PI/2 + I*PI/2) = %e + I * %e\n", zreals(out), zimags(out));
  out = zacoshs(pi_2_pi_3);
  printf("zacoshs(PI/2 + I*PI/3) = %e + I * %e\n", zreals(out), zimags(out));
  out = zacoshs(pi_2_pi_4);
  printf("zacoshs(PI/2 + I*PI/4) = %e + I * %e\n", zreals(out), zimags(out));
}

void sacoshaTest(void) {
  float out[5];
  float in[5] = {PI, PI/2, PI/3, PI/4, PI/6};
  int i = 0;

  printf(">> Float array\n");
  sacosha(in, 5, out);
  for (i = 0 ; i < 5 ; ++i)
    printf("sacosha(array) = %f\n", out[i]);
}

void dacoshaTest(void) {
  double out[5];
  double in[5] = {PI, PI/2, PI/3, PI/4, PI/6};
  int i = 0;

  printf(">> Double Array\n");
  dacosha(in, 5, out);
  for (i = 0 ; i < 5 ; ++i)
    printf("sacosha(array) = %f\n", out[i]);

}

void cacoshaTest(void) {
  floatComplex in[4];
  floatComplex out[4];
  int i = 0;

  in[0] = FloatComplex(PI, PI);
  in[1] = FloatComplex(PI/2, PI/2);
  in[2] = FloatComplex(PI/2, PI/3);
  in[3] = FloatComplex(PI/2, PI/4);

  cacosha(in, 4, out);
  printf(">> Float Complex Array\n");
  for (i = 0 ; i < 4 ; ++i)
    printf("cacosha(array) = %e + I * %e\n", creals(out[i]), cimags(out[i]));
}

void zacoshaTest(void) {
  doubleComplex in[4];
  doubleComplex out[4];
  int i = 0;

  in[0] = DoubleComplex(PI, PI);
  in[1] = DoubleComplex(PI/2, PI/2);
  in[2] = DoubleComplex(PI/2, PI/3);
  in[3] = DoubleComplex(PI/2, PI/4);

  zacosha(in, 4, out);
  printf(">> Double Complex Array\n");
  for (i = 0 ; i < 4 ; ++i)
    printf("zacosha(array) = %e + I * %e\n", zreals(out[i]), zimags(out[i]));
}

int testAcosh(void) {
  printf("\n>>>> ArcCoshine Tests\n");
  sacoshsTest();
  dacoshsTest();
  cacoshsTest();
  zacoshsTest();
  sacoshaTest();
  dacoshaTest();
  cacoshaTest();
  zacoshaTest();
  return 0;
}

int main(void) {
  assert(testAcosh() == 0);
  return 0;
}