/* compute the gram matrix of a set of profiles */ # include "svm_common.h" # include "kernel.h" int main (int argc, char* argv[]) { DOC *docs; /* training examples */ long *label,max_docs,max_words_doc; long totwords,totdoc,ll,i,j; if (argc != 2) printf("Usage: compute_gram example_file\n"); else { nol_ll(argv[1],&max_docs,&max_words_doc,&ll); /* scan size of input file */ max_words_doc+=2; ll+=2; max_docs+=2; docs = (DOC *)my_malloc(sizeof(DOC)*max_docs); label = (long *)my_malloc(sizeof(long)*max_docs); read_documents(argv[1],docs,label,max_words_doc,ll,&totwords,&totdoc); /* Compute the Gram matrix */ printf("K = ["); for (i=0 ; iwords,(docs+j)->words)); } if (i