-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* convert all current work to double as default * add initial test for gain function * add display_gather function for fun
- Loading branch information
1 parent
ae49abf
commit fe6dbd3
Showing
3 changed files
with
92 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,79 @@ | ||
#include "gtest/gtest.h" | ||
|
||
extern "C" { | ||
#include <math.h> | ||
#include "libseis.h" | ||
} | ||
|
||
int const nt_test = 10; | ||
int const nx_test = 1; | ||
|
||
float float_trace1[nt_test] = { | ||
0.000, | ||
2.000, | ||
4.000, | ||
8.000, | ||
1.000, | ||
2.000, | ||
3.000, | ||
4.000, | ||
5.000, | ||
6.000, | ||
double double_trace1[nt_test] = { | ||
0.000, | ||
2.000, | ||
4.000, | ||
8.000, | ||
1.000, | ||
2.000, | ||
3.000, | ||
4.000, | ||
5.000, | ||
6.000, | ||
}; | ||
|
||
float cmp_array[nt_test * 2] = { | ||
0.000, | ||
2.000, | ||
4.000, | ||
8.000, | ||
1.000, | ||
2.000, | ||
3.000, | ||
4.000, | ||
5.000, | ||
6.000, | ||
0.000, | ||
0.000, | ||
1.000, | ||
0.020, | ||
0.301, | ||
-0.101, | ||
0.035, | ||
0.011, | ||
-0.006, | ||
0.009, | ||
double cmp_array[nt_test * 2] = { | ||
0.000, | ||
2.000, | ||
4.000, | ||
8.000, | ||
1.000, | ||
2.000, | ||
3.000, | ||
4.000, | ||
5.000, | ||
6.000, | ||
0.000, | ||
0.000, | ||
1.000, | ||
0.020, | ||
0.301, | ||
-0.101, | ||
0.035, | ||
0.011, | ||
-0.006, | ||
0.009, | ||
}; | ||
|
||
struct Gather cmp = { | ||
1, | ||
nt_test, | ||
2, | ||
1, | ||
cmp_array, | ||
DOUBLE | ||
1, | ||
nt_test, | ||
2, | ||
1, | ||
cmp_array, | ||
DOUBLE | ||
}; | ||
|
||
TEST(HelloTest, ExampleTest) { | ||
EXPECT_EQ(7 * 6, 42); | ||
} | ||
|
||
TEST(LibseisIO, ReadWriteFloat) { | ||
char tmp_file[] = "/tmp/data.bin"; | ||
write_float(tmp_file, float_trace1, nt_test, nx_test); | ||
float *data = read_float(tmp_file, nt_test, nx_test); | ||
write_double(tmp_file, double_trace1, nt_test, nx_test); | ||
double *data = read_double(tmp_file, nt_test, nx_test); | ||
for (int i = 0; i < nt_test; i++) { | ||
EXPECT_EQ(data[i], float_trace1[i]); | ||
EXPECT_EQ(data[i], double_trace1[i]); | ||
} | ||
} | ||
|
||
TEST(GainCmp, GainsCmpGather) { | ||
float t_pow = 2; | ||
double t_pow = 2; | ||
Gather *foo = gain_gather(&cmp, t_pow); | ||
printf("%d\n", foo->nt); | ||
EXPECT_EQ(0, 0); | ||
|
||
printf("Check that the t^power function operates correctly"); | ||
for (int i = 0; i < foo->nt; i++) { | ||
printf("%f * (%f^%f) = %f\n", cmp.data[i], foo->dt * i, t_pow, foo->data[i]); | ||
double t_powered = cmp.data[i] * pow(foo->dt * i, t_pow); | ||
EXPECT_EQ(foo->data[i], t_powered); | ||
} | ||
} | ||
|
||
TEST(Gather, GatherDisplay) { | ||
display_gather(&cmp); | ||
} |