Commit c42a95f1 by Ethan

added macros and comments

parent 31b0c44b
File added
......@@ -8,11 +8,11 @@
#include <time.h>
#define RIVSIZE 5000
#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"
#define THRESHOLD .80f
void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount);
int printname(float cosine, sparseRIV base, sparseRIV multiplier);
int main(int argc, char *argv[]){
clock_t begintotal = clock();
......@@ -35,7 +35,7 @@ int main(int argc, char *argv[]){
printf("got past magnitudes");
for(int i=0; i<fileCount; i++){
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){
}
}
}
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 @@
#include <math.h>
#include "RIVLower.h"
#ifndef COSINEACTION
#define COSINEACTION
#endif
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"
......@@ -34,7 +37,7 @@ sparseRIV fileToL2(FILE *input);
sparseRIV fileToL2Clean(FILE *data);
/* 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 */
void getMagnitudes(sparseRIV *inputs, size_t RIVCount);
......@@ -130,7 +133,7 @@ sparseRIV fileToL2Clean(FILE *data){
output.boolean = 1;
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;
mapS2D(baseDenseRIV, baseRIV);
......@@ -167,8 +170,9 @@ void cosineCompare(sparseRIV baseRIV, sparseRIV *multipliers, size_t multiplierC
/* magnitudes had better already be calculated at this point*/
cosSim= dot/((baseRIV.magnitude)*((*multipliers).magnitude));
/* perform the action defined by the acction function */
action(cosSim, baseRIV, (*multipliers));
/* perform the action defined by the action function */
//action(cosSim, baseRIV, (*multipliers));
COSINEACTION
}
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