Commit c42a95f1 by Ethan

added macros and comments

parent 31b0c44b
File added
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#include <time.h> #include <time.h>
#define RIVSIZE 5000 #define RIVSIZE 5000
#define CACHESIZE 0 #define CACHESIZE 0
#define THRESHOLD 0.70
#define COSINEACTION if(cosSim > THRESHOLD){ printf("%s\t%s\n%f\n", baseRIV.name, (*multipliers).name, cosSim); (*multipliers).boolean = 0; RIVKey.thing++; }
#include "RIVtoolsCPUlinux.h" #include "RIVtoolsCPUlinux.h"
#define THRESHOLD .80f
void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount); void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount);
int printname(float cosine, sparseRIV base, sparseRIV multiplier);
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
clock_t begintotal = clock(); clock_t begintotal = clock();
...@@ -35,7 +35,7 @@ int main(int argc, char *argv[]){ ...@@ -35,7 +35,7 @@ int main(int argc, char *argv[]){
printf("got past magnitudes"); printf("got past magnitudes");
for(int i=0; i<fileCount; i++){ for(int i=0; i<fileCount; i++){
if(fileRIVs[i].boolean){ if(fileRIVs[i].boolean){
cosineCompare(fileRIVs[i], fileRIVs+i+1, fileCount-(i+1), printname); cosineCompare(fileRIVs[i], fileRIVs+i+1, fileCount-(i+1));
} }
} }
...@@ -90,13 +90,3 @@ void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount){ ...@@ -90,13 +90,3 @@ void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount){
} }
} }
} }
int printname(float cosine, sparseRIV base, sparseRIV multiplier){
if(cosine>= THRESHOLD){
printf("%s\t%s\n%f\n", base.name, multiplier.name, cosine);
multiplier.boolean = 0;
RIVKey.thing++;
return 0;
}
return 0;
}
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include <math.h> #include <math.h>
#include "RIVLower.h" #include "RIVLower.h"
#ifndef COSINEACTION
#define COSINEACTION
#endif
void cosineCompareUnbound(sparseRIV baseRIV, sparseRIV *multipliers, size_t multiplierCount, float threshold); void cosineCompareUnbound(sparseRIV baseRIV, sparseRIV *multipliers, size_t multiplierCount, float threshold);
/*lexPush writes a denseRIV to a file of the same name, under the directory "lexicon" /*lexPush writes a denseRIV to a file of the same name, under the directory "lexicon"
...@@ -34,7 +37,7 @@ sparseRIV fileToL2(FILE *input); ...@@ -34,7 +37,7 @@ sparseRIV fileToL2(FILE *input);
sparseRIV fileToL2Clean(FILE *data); sparseRIV fileToL2Clean(FILE *data);
/* cosine determines the "similarity" between two RIVs. */ /* cosine determines the "similarity" between two RIVs. */
void cosineCompare(sparseRIV baseRIV, sparseRIV *multipliers, size_t multiplierCount, int (*action)(float cosine, sparseRIV base, sparseRIV multiplier)); void cosineCompare(sparseRIV baseRIV, sparseRIV *multipliers, size_t multiplierCount);
/* magnitudes will be used later in cosine comparison */ /* magnitudes will be used later in cosine comparison */
void getMagnitudes(sparseRIV *inputs, size_t RIVCount); void getMagnitudes(sparseRIV *inputs, size_t RIVCount);
...@@ -130,7 +133,7 @@ sparseRIV fileToL2Clean(FILE *data){ ...@@ -130,7 +133,7 @@ sparseRIV fileToL2Clean(FILE *data){
output.boolean = 1; output.boolean = 1;
return output; return output;
} }
void cosineCompare(sparseRIV baseRIV, sparseRIV *multipliers, size_t multiplierCount, int (*action)(float cosine, sparseRIV base, sparseRIV multiplier)){ void cosineCompare(sparseRIV baseRIV, sparseRIV *multipliers, size_t multiplierCount){
int *baseDenseRIV = RIVKey.h_tempBlock; int *baseDenseRIV = RIVKey.h_tempBlock;
mapS2D(baseDenseRIV, baseRIV); mapS2D(baseDenseRIV, baseRIV);
...@@ -167,8 +170,9 @@ void cosineCompare(sparseRIV baseRIV, sparseRIV *multipliers, size_t multiplierC ...@@ -167,8 +170,9 @@ void cosineCompare(sparseRIV baseRIV, sparseRIV *multipliers, size_t multiplierC
/* magnitudes had better already be calculated at this point*/ /* magnitudes had better already be calculated at this point*/
cosSim= dot/((baseRIV.magnitude)*((*multipliers).magnitude)); cosSim= dot/((baseRIV.magnitude)*((*multipliers).magnitude));
/* perform the action defined by the acction function */ /* perform the action defined by the action function */
action(cosSim, baseRIV, (*multipliers)); //action(cosSim, baseRIV, (*multipliers));
COSINEACTION
} }
multipliers++; multipliers++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment