-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathseries-exp.cc
42 lines (35 loc) · 950 Bytes
/
series-exp.cc
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
// Exponentiate a series
#include "expansion_arith.h"
#include "series.h"
#include <unistd.h>
using namespace mandelbrot;
void exp(const string& input, const string& output) {
// Verify that output file doesn't exist
print("%s = exp(%s)", output, input);
slow_assert(access(output.c_str(), F_OK) == -1, "%s exists", output);
// Read series, assuming exp2 for now
#ifndef __CUDACC__
typedef Expansion<2> S;
#else
typedef Device<Expansion<2>> S;
#endif
print("reading...");
const auto [_, x] = read_series<S>(input);
// Exponentiate
print("exponentiating...");
Series<S> y(x.nonzero());
y = exp(x);
// Write output
print("writing...");
write_series_npy<S>(output, y);
print("done");
}
int main(const int argc, const char** argv) {
try {
slow_assert(argc == 3, "usage %s <input> <output.npy>", argv[0]);
exp(argv[1], argv[2]);
return 0;
} catch (const std::exception& e) {
die(e.what());
}
}