-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from edin-dal/fix/using-symbols-in-operations
Symbols can be used as a part of the computation
- Loading branch information
Showing
5 changed files
with
131 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
symbols: N | ||
A(i) := B(i) * N^-1() | ||
A:D(i) := (0 <= i < N) | ||
B:D(i) := (0 <= i < N) |
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
50 changes: 50 additions & 0 deletions
50
src/test/resources/correct_test_outputs/symbol-computation_w_body.cpp
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
#include <iostream> | ||
#include <random> | ||
#include <algorithm> | ||
#include <chrono> | ||
|
||
using namespace std; | ||
using namespace std::chrono; | ||
|
||
int main(int argc, char **argv){ | ||
srand(0); | ||
|
||
|
||
const int N = atoi(argv[1]); | ||
double *B = new double[N]; | ||
for (size_t i = 0; i < N; ++i) { | ||
int flag1 = 0 <= i && N > i; | ||
if (flag1) { | ||
B[i] = (double) (rand() % 1000000) / 1e6; | ||
} else { | ||
B[i] = 0.0; | ||
} | ||
} | ||
double *A = new double[N]; | ||
for (size_t i = 0; i < N; ++i) { | ||
A[i] = 0.0; | ||
} | ||
|
||
long time_computation = 0, start_computation, end_computation; | ||
start_computation = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count(); | ||
for (int i = 0; i < N; ++i) { | ||
|
||
A[i] += (1. / N * B[i]); | ||
} | ||
end_computation = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count(); | ||
time_computation = end_computation - start_computation; | ||
cout << time_computation << endl; | ||
long time_reconstruction = 0, start_reconstruction, end_reconstruction; | ||
start_reconstruction = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count(); | ||
|
||
end_reconstruction = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count(); | ||
time_reconstruction = end_reconstruction - start_reconstruction; | ||
cout << time_reconstruction << endl; | ||
cerr << A[0] << endl; | ||
cerr << B[0] << endl; | ||
cerr << N << endl; | ||
delete[] A; | ||
delete[] B; | ||
return 0; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/resources/correct_test_outputs/symbol-computation_wo_body.cpp
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
#include <iostream> | ||
#include <random> | ||
#include <algorithm> | ||
#include <chrono> | ||
|
||
using namespace std; | ||
using namespace std::chrono; | ||
|
||
extern "C" | ||
void fn(double * A, double * B, int N) { | ||
|
||
|
||
long time_computation = 0, start_computation, end_computation; | ||
start_computation = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count(); | ||
for (int i = 0; i < N; ++i) { | ||
|
||
A[i] += (1. / N * B[i]); | ||
} | ||
end_computation = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count(); | ||
time_computation = end_computation - start_computation; | ||
cout << time_computation << endl; | ||
long time_reconstruction = 0, start_reconstruction, end_reconstruction; | ||
start_reconstruction = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count(); | ||
|
||
end_reconstruction = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count(); | ||
time_reconstruction = end_reconstruction - start_reconstruction; | ||
cout << time_reconstruction << endl; | ||
|
||
} |
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