You've already forked Zygisk-Assistant
mirror of
https://github.com/snake-4/Zygisk-Assistant.git
synced 2025-09-06 06:37:02 +00:00
Initial commit
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// abs(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {1.5, -2.5, 3.4, -4.5, -5.0};
|
||||
T a3[] = {1.5, 2.5, 3.4, 4.5, 5.0};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = abs(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(v3[i] == a3[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// acos(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {2.6905658417935308e+00,
|
||||
2.0943951023931957e+00,
|
||||
1.5707963267948966e+00,
|
||||
1.0471975511965976e+00,
|
||||
7.2273424781341566e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = acos(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// asin(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {-1.1197695149986342e+00,
|
||||
-5.2359877559829882e-01,
|
||||
0.0000000000000000e+00,
|
||||
5.2359877559829882e-01,
|
||||
8.4806207898148100e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = asin(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// atan2(const valarray<T>& x, const valarray<T>& y);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a2[] = {-.8, .25, 0.375, -.5, .75};
|
||||
T a3[] = {-2.2974386674766221e+00,
|
||||
-1.1071487177940904e+00,
|
||||
0.0000000000000000e+00,
|
||||
2.3561944901923448e+00,
|
||||
7.8539816339744828e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v2(a2, N);
|
||||
std::valarray<T> v3 = atan2(v1, v2);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// atan2(const valarray<T>& x, const T& y);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {-8.7605805059819342e-01,
|
||||
-5.8800260354756750e-01,
|
||||
0.0000000000000000e+00,
|
||||
5.8800260354756750e-01,
|
||||
7.8539816339744828e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = atan2(v1, .75);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// atan2(const T& x, const valarray<T>& y);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {2.4468543773930902e+00,
|
||||
2.1587989303424640e+00,
|
||||
1.5707963267948966e+00,
|
||||
9.8279372324732905e-01,
|
||||
7.8539816339744828e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = atan2(.75, v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// atan(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {-7.3281510178650666e-01,
|
||||
-4.6364760900080615e-01,
|
||||
0.0000000000000000e+00,
|
||||
4.6364760900080615e-01,
|
||||
6.4350110879328437e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = atan(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// cos(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {6.2160996827066450e-01,
|
||||
8.7758256189037276e-01,
|
||||
1.0000000000000000e+00,
|
||||
8.7758256189037276e-01,
|
||||
7.3168886887382090e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = cos(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// cosh(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {1.4330863854487743e+00,
|
||||
1.1276259652063807e+00,
|
||||
1.0000000000000000e+00,
|
||||
1.1276259652063807e+00,
|
||||
1.2946832846768448e+00};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = cosh(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// exp(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {4.0656965974059911e-01,
|
||||
6.0653065971263342e-01,
|
||||
1.0000000000000000e+00,
|
||||
1.6487212707001282e+00,
|
||||
2.1170000166126748e+00};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = exp(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// log10(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {.5, .75, 1, 3, 7};
|
||||
T a3[] = {-3.0102999566398120e-01,
|
||||
-1.2493873660829995e-01,
|
||||
0.0000000000000000e+00,
|
||||
4.7712125471966244e-01,
|
||||
8.4509804001425681e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = log10(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// log(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {.5, .75, 1, 3, 7};
|
||||
T a3[] = {-6.9314718055994529e-01,
|
||||
-2.8768207245178090e-01,
|
||||
0.0000000000000000e+00,
|
||||
1.0986122886681098e+00,
|
||||
1.9459101490553132e+00};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = log(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// pow(const valarray<T>& x, const valarray<T>& y);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {.9, .5, 0., .5, .75};
|
||||
T a2[] = {-.8, .25, 0.375, -.5, .75};
|
||||
T a3[] = {1.0879426248455297e+00,
|
||||
8.4089641525371450e-01,
|
||||
0.0000000000000000e+00,
|
||||
1.4142135623730949e+00,
|
||||
8.0592744886765644e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v2(a2, N);
|
||||
std::valarray<T> v3 = pow(v1, v2);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// pow(const valarray<T>& x, const T& y);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {.9, .5, 0., .5, .75};
|
||||
T a3[] = {8.1000000000000005e-01,
|
||||
2.5000000000000000e-01,
|
||||
0.0000000000000000e+00,
|
||||
2.5000000000000000e-01,
|
||||
5.6250000000000000e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = pow(v1, 2.0);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// pow(const T& x, const valarray<T>& y);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {.9, .5, 0., .5, .75};
|
||||
T a3[] = {1.8660659830736148e+00,
|
||||
1.4142135623730951e+00,
|
||||
1.0000000000000000e+00,
|
||||
1.4142135623730951e+00,
|
||||
1.6817928305074290e+00};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = pow(2.0, v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// sin(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {-7.8332690962748330e-01,
|
||||
-4.7942553860420301e-01,
|
||||
0.0000000000000000e+00,
|
||||
4.7942553860420301e-01,
|
||||
6.8163876002333423e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = sin(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// sinh(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {-1.0265167257081753e+00,
|
||||
-5.2109530549374738e-01,
|
||||
0.0000000000000000e+00,
|
||||
5.2109530549374738e-01,
|
||||
8.2231673193582999e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = sinh(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// sqrt(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {.5, .75, 1, 3, 7};
|
||||
T a3[] = {7.0710678118654757e-01,
|
||||
8.6602540378443860e-01,
|
||||
1.0000000000000000e+00,
|
||||
1.7320508075688772e+00,
|
||||
2.6457513110645907e+00};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = sqrt(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// tan(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {-1.2601582175503390e+00,
|
||||
-5.4630248984379048e-01,
|
||||
0.0000000000000000e+00,
|
||||
5.4630248984379048e-01,
|
||||
9.3159645994407259e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = tan(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <valarray>
|
||||
|
||||
// template<class T> class valarray;
|
||||
|
||||
// template<class T>
|
||||
// valarray<T>
|
||||
// tanh(const valarray<T>& x);
|
||||
|
||||
#include <valarray>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "valarray_helper.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
T a1[] = {-.9, -.5, 0., .5, .75};
|
||||
T a3[] = {-7.1629787019902447e-01,
|
||||
-4.6211715726000974e-01,
|
||||
0.0000000000000000e+00,
|
||||
4.6211715726000974e-01,
|
||||
6.3514895238728730e-01};
|
||||
const unsigned N = sizeof(a1)/sizeof(a1[0]);
|
||||
std::valarray<T> v1(a1, N);
|
||||
std::valarray<T> v3 = tanh(v1);
|
||||
assert(v3.size() == v1.size());
|
||||
for (std::size_t i = 0; i < v3.size(); ++i)
|
||||
assert(is_about(v3[i], a3[i], 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#ifndef LIBCPP_TEST_VALARRAY_HELPER_H
|
||||
#define LIBCPP_TEST_VALARRAY_HELPER_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
// Returns whether `x` and `y` are equal, up to the given number of
|
||||
// significant digits after the decimal.
|
||||
//
|
||||
// Specifically, we look whether `abs(x - y) < epsilon`, where epsilon
|
||||
// is `(1 / 10)^p`, assuming p is the number of digits we care about.
|
||||
// This means we're basically looking whether `abs(x - y)` is less
|
||||
// than `0.00..001` for some number of digits.
|
||||
inline bool is_about(double x, double y, int significant_digits) {
|
||||
double epsilon = std::pow(1.0 / 10.0, significant_digits);
|
||||
return std::abs(x - y) < epsilon;
|
||||
}
|
||||
|
||||
#endif /* LIBCPP_TEST_VALARRAY_HELPER */
|
||||
Reference in New Issue
Block a user