about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhanemile <emile.hansmaennel@gmail.com>2018-01-01 20:11:15 +0100
committerhanemile <emile.hansmaennel@gmail.com>2018-01-01 20:11:15 +0100
commit7f409708c3ca3e0af213efa4d6f8390b4f46f78e (patch)
tree53d150b4950221c8f1e916f9c3b9718d432d730d
parentf6d0ee87d389bdb9c1cbac7bc9d38dccf989165c (diff)
update
-rwxr-xr-xsrc/c/lookupbin0 -> 13200 bytes
-rw-r--r--src/c/lookup.c74
-rwxr-xr-xsrc/c/readbin0 -> 12880 bytes
-rw-r--r--src/c/read.c52
-rw-r--r--src/c/testFile.csv100
5 files changed, 226 insertions, 0 deletions
diff --git a/src/c/lookup b/src/c/lookup
new file mode 100755
index 0000000..6a6368d
--- /dev/null
+++ b/src/c/lookup
Binary files differdiff --git a/src/c/lookup.c b/src/c/lookup.c
new file mode 100644
index 0000000..01b5508
--- /dev/null
+++ b/src/c/lookup.c
@@ -0,0 +1,74 @@
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+
+// Define some variables
+int sigma = 200;
+float f_0 = 0.1;
+float R_s = 1e4;
+
+// Define some constants
+float pi = M_PI;
+float e = M_E;
+float G = 4.302e-3;
+
+// Define the directory where the data shall be stored
+
+// Prototype
+float rho(float r);
+float phi(float x);
+
+int main(int argc, char *argv[] ){
+  if( argc == 2 ) {
+    printf("Generating %s Values...\n", argv[1]);
+
+    FILE * fp = fopen("testFile.csv", "w+");
+    if(fp == NULL){
+      printf("Error opening the file!\n");
+      exit(1);
+    }
+
+    int x = atoi(argv[1]);
+
+    for(int i = 0; i < x; i++){
+      fprintf(fp, "%d, %f\n", i, phi(i));
+    }
+
+    // for(int i = 0; i < 1e7; i = i + 1e4){
+    //   printf("%s, %f\n", i, phi(i));
+    // }
+
+    fclose(fp);
+
+  }
+  else if( argc > 2 ) {
+    printf("Too many arguments supplied.\n");
+    return 0;
+  }
+  else {
+    printf("One argument expected.\n");
+    return 0;
+  }
+
+  return 0;
+}
+
+// Define rho function
+float rho(float r){
+  float a = (1) / ( sqrt(2 * pi) * sigma);
+  float b = exp( - (phi(r) / pow(sigma, 2) ));
+  return a;
+}
+
+// Define phi function
+float phi(float x){
+  if(x == 0) {
+    float a = -4 * pi * f_0 * G * pow(R_s, 2);
+    return(a);
+  }
+  else {
+    float a = - (4 * pi * G * f_0 * pow(R_s, 3) / x);
+    float b = log(1 + (x / R_s) );
+    return(a * b);
+  }
+}
diff --git a/src/c/read b/src/c/read
new file mode 100755
index 0000000..97751d7
--- /dev/null
+++ b/src/c/read
Binary files differdiff --git a/src/c/read.c b/src/c/read.c
new file mode 100644
index 0000000..109c603
--- /dev/null
+++ b/src/c/read.c
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <math.h>
+
+// Define some constants
+int range = 100;
+
+// Prototype pythagoras function
+float pythagoras(int x, int y, int z);
+
+int main(int argc, char *argv[] ){
+  // Seed random
+  srand(time(NULL));
+
+  // Define the number of stars that should be generated using command line
+  // arguments
+  long num_of_stars = atoi(argv[1]);
+
+  // define an array to store the coordinates of the stars in
+  int star_arr[num_of_stars][3];
+
+  // generate the random coordinates
+  for(int i = 0; i < num_of_stars; i++){
+    star_arr[i][0] = rand() % range + 1;
+    star_arr[i][1] = rand() % range + 1;
+    star_arr[i][2] = rand() % range + 1;
+  }
+
+  // print the content of the array star_arr
+  for(int i = 0; i < num_of_stars; i++){
+    printf("%d, %d, %d\n", star_arr[i][0], star_arr[i][1], star_arr[i][2]);
+    printf("%f\n\n", pythagoras(star_arr[i][0], star_arr[i][1], star_arr[i][2]));
+
+  }
+
+  // Test if the Star should be generated or not
+
+    // If the star should be generated, write it's coordinates to a file
+    // Else do nothing
+
+  return 0;
+}
+
+float pythagoras(int x, int y, int z){
+  float a = pow(x, 2);
+  float b = pow(y, 2);
+  float c = pow(z, 2);
+  float d = a + b + c;
+  float e = sqrt(d);
+  return e;
+}
diff --git a/src/c/testFile.csv b/src/c/testFile.csv
new file mode 100644
index 0000000..3568a06
--- /dev/null
+++ b/src/c/testFile.csv
@@ -0,0 +1,100 @@
+0, -540605.250000
+1, -540668.000000
+2, -540640.937500
+3, -540613.937500
+4, -540425.875000
+5, -540431.062500
+6, -540425.500000
+7, -540413.812500
+8, -540398.375000
+9, -540380.312500
+10, -540360.375000
+11, -540280.750000
+12, -540263.562500
+13, -540244.812500
+14, -540224.875000
+15, -540204.062500
+16, -540182.437500
+17, -540160.187500
+18, -540101.687500
+19, -540080.375000
+20, -540058.500000
+21, -540036.125000
+22, -540013.312500
+23, -539990.187500
+24, -539966.812500
+25, -539943.062500
+26, -539894.375000
+27, -539871.062500
+28, -539847.500000
+29, -539823.750000
+30, -539799.812500
+31, -539775.687500
+32, -539751.312500
+33, -539707.375000
+34, -539683.375000
+35, -539659.125000
+36, -539634.750000
+37, -539610.312500
+38, -539585.687500
+39, -539560.937500
+40, -539520.000000
+41, -539495.562500
+42, -539470.875000
+43, -539446.125000
+44, -539421.312500
+45, -539396.375000
+46, -539371.375000
+47, -539332.625000
+48, -539307.750000
+49, -539282.812500
+50, -539257.812500
+51, -539232.687500
+52, -539207.562500
+53, -539182.312500
+54, -539145.187500
+55, -539120.062500
+56, -539094.937500
+57, -539069.687500
+58, -539044.437500
+59, -539019.125000
+60, -538993.750000
+61, -538968.312500
+62, -538932.562500
+63, -538907.187500
+64, -538881.812500
+65, -538856.375000
+66, -538830.937500
+67, -538805.437500
+68, -538779.937500
+69, -538745.125000
+70, -538719.687500
+71, -538694.125000
+72, -538668.625000
+73, -538643.125000
+74, -538617.500000
+75, -538591.875000
+76, -538557.812500
+77, -538532.312500
+78, -538506.750000
+79, -538481.062500
+80, -538455.437500
+81, -538429.812500
+82, -538404.187500
+83, -538370.750000
+84, -538345.125000
+85, -538319.437500
+86, -538293.750000
+87, -538268.062500
+88, -538242.375000
+89, -538216.625000
+90, -538183.750000
+91, -538158.062500
+92, -538132.312500
+93, -538106.625000
+94, -538080.875000
+95, -538055.125000
+96, -538029.312500
+97, -538003.500000
+98, -537971.187500
+99, -537945.437500