-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split out distance function. All shared functions are now separated.
- Loading branch information
EC2 Default User
committed
Apr 16, 2017
1 parent
a751fca
commit 3df024d
Showing
5 changed files
with
18 additions
and
10 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.swp | ||
*.out | ||
*.nc | ||
__pycache__ |
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,4 +1,4 @@ | ||
gcc -O2 -std=c99 -lnetcdf -fopenmp -lpthread ../shared/make_2D_array.c ../shared/ncdf_util.c Kmean_omp.c -o Kmean_omp.out | ||
gcc -o Kmean_omp.out -O2 -std=c99 -lnetcdf -fopenmp -lpthread ../shared/make_2D_array.c ../shared/ncdf_util.c ../shared/math_util.c Kmean_omp.c | ||
|
||
#For debugging with gdb | ||
#gcc -g -O0 -std=c99 -lnetcdf Kmean_seq.c -o Kmean_seq.out |
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,9 @@ | ||
#include "math_util.h" | ||
|
||
// square of the distance between x1[N_features] and x2[N_features] | ||
float distance(int N_features,float *x1,float *x2){ | ||
float dist=0.0; | ||
for (int j=0; j<N_features; j++) | ||
dist += (x1[j]-x2[j])*(x1[j]-x2[j]); | ||
return(dist); | ||
} |
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,6 @@ | ||
#ifndef MATH_UTIL_H | ||
#define MATH_UTIL_H | ||
|
||
float distance(int N_features,float *x1,float *x2); | ||
|
||
#endif // MATH_UTIL_H |