StereoRecorder::StereoRecorder(bool fromFile) { is_truncated = is_processed = false; if ( fromFile ) { stamped_offset = 0; Read(false); assertid("OUT2"); filename = ReadString(); float t = ReadFloat(); if ( Datatype::PeakId() == "anim" ) { animation = new Animated<gmtl::Point3f>(); } else { setLocation(ReadPoint()); animation = 0; } if ( Datatype::PeakId() == "anim" ) { right_ear_animation = new Animated<gmtl::Vec3f>(); } else { right_ear = ReadVec(); right_ear_animation = 0; } head_size = ReadFloat(); head_absorption = ReadVec(); for ( unsigned int i = 0; i < 3; ++ i ) { head_absorption[i] = std::max(0.0f,powf(1.0f-head_absorption[i],4)); } std::cout << this->toString(); } else { animation = 0; right_ear_animation = 0; filename = ""; } has_samples = save_processed = false; tracks.push_back(new RecorderTrack()); tracks.push_back(new RecorderTrack()); }
void OpVecVec (TomVM &vm) { // Vector * Vector = dot product // Fetch vectors if (ReadVec (vm, vm.Reg2 ().IntVal (), v1) < 0 || ReadVec (vm, vm.Reg ().IntVal (), v2) < 0) return; // Return result vm.Reg ().RealVal () = DotProduct (v1, v2); }
void OpVecMinusVec (TomVM& vm) { // Fetch vectors int s1 = ReadVec (vm, vm.Reg2 ().IntVal (), v1), s2 = ReadVec (vm, vm.Reg ().IntVal (), v2); if (s1 < 0 || s2 < 0) return; // Calculate result vmReal result [4]; VecMinus (v1, v2, result); // Return as temporary vector vm.Reg ().IntVal () = FillTempRealArray (vm.Data (), vm.DataTypes (), max (s1, s2), result); }
void WrapCross (TomVM& vm) { // Fetch vectors int s1 = ReadVec (vm, vm.GetIntParam (2), v1), s2 = ReadVec (vm, vm.GetIntParam (1), v2); if (s1 < 0 || s2 < 0) return; // Calculate cross product vector vmReal result [4]; CrossProduct (v1, v2, result); // Return resulting vector // (Vector will be the same length as the first source vector) vm.Reg ().IntVal () = FillTempRealArray (vm.Data (), vm.DataTypes (), max (max (s1, s2), 3), result); }
void WrapLength (TomVM& vm) { // Fetch vector if (ReadVec (vm, vm.GetIntParam (1), v1) < 0) return; // Calculate length vm.Reg ().RealVal () = Length (v1); }
//////////////////////////////////////////////////////////////////////////////// // Overloaded operators void DoScaleVec (TomVM& vm, vmReal scale, int vecIndex) { // Extract data int size = ReadVec (vm, vecIndex, v1); if (size < 0) return; // Scale 3D vector Scale (v1, scale); // Return as temp vector (using original size) vm.Reg ().IntVal () = FillTempRealArray (vm.Data (), vm.DataTypes (), size, v1); }
void WrapNormalize (TomVM& vm) { // Fetch vector int size = ReadVec (vm, vm.GetIntParam (1), v1); if (size < 0) return; // Normalize vector Normalize (v1); // Return resulting vector vm.Reg ().IntVal () = FillTempRealArray (vm.Data (), vm.DataTypes (), size, v1); }
/*************************************************************************************************************************** Main Function(Serial and Parallel Fault Simulation) ****************************************************************************************************************************/ void main(int argc,char **argv) { FILE *fisc,*fvec,*ffau,*fres; //file pointers used for .isc file, .vec file, .faults file and resultfile int Max,Opt,Npi,Npo,Tot,Tfs; //maxnode id,option,tot no of PIs,tot no of Pos,Tot no of input patterns& faults in.vec in.faults clock_t is,it; //execution time clock signals double iexe; //execution time NODE graph[Mnod]; //structure used to store the ckt information in .isc file PATTERN vector[Mpt]; //structure used to store the input vectors information in .vec file FAULT struck[Mft]; //structure used to store the faults information in .faults file int a,b,c,d; //random variables //Read the .isc file and store the information in graph structure is=clock(); //starting timer fisc=fopen(argv[1],"r"); //file pointer to open .isc file Max=0; Max=ReadIsc(fisc,graph); //read .isc file and return index of last node in graph formed fclose(fisc); //close file pointer for .isc file it=clock(); //ending the timer iexe=((double)(it-is))/CLOCKS_PER_SEC; //execuetion time calculation PrintCircuit(graph,Max); //print all members of graph structure printf("\nTime Taken for ISC File: %f",iexe); //print execuetion time //Read the .vec file and store the information in vector structure fvec=fopen(argv[2],"r"); //file pointer to open .vec file Tot=0; Tot=ReadVec(fvec,vector); //read .vec file and store in vector structure and return tot number of patterns printf("\nTot No of Pattern: %d",Tot); //print total number of patterns in .vec file fclose(fvec); //close file pointer for .vec file printf("\nIndex\tInputVector\n"); for(a=0;a<Tot;a++){ printf("%d\t%s",a,vector[a].piv); } //print all members of vector structure ffau=fopen(argv[4],"r"); Tfs = Readfault(ffau,struck); fclose(ffau); for(a=0;a<Tfs;a++){ printf("%d/%d \n",struck[a].nod,struck[a].sval); } fres=fopen(argv[3],"w"); //file pointer to open .out file for printing results readgraph(graph, vector, fres, Max,Tot,struck,Tfs); //call the readgraph function to process and print outputs //Perform Logic Simulationfor each Input vector and print the Pos .val in output file fclose(fres); //close file pointer for .out file ClearCircuit(graph,Mnod); //clear memeory for all members of graph for(a=0;a<Tot;a++){ bzero(vector[a].piv,Mpi); } //clear memeory for all members of vector return; }//end of main
void OpMatrixVec (TomVM& vm) { // Matrix at reg2. Vector at reg. // Read in matrix if (!ReadMatrix (vm, vm.Reg2 ().IntVal (), m1)) return; // Read in vector int size = ReadVec (vm, vm.Reg ().IntVal (), v1); if (size < 0) return; // Calculate resulting vector vmReal result [4]; MatrixTimesVec (m1, v1, result); // Return as temporary vector vm.Reg ().IntVal () = FillTempRealArray (vm.Data (), vm.DataTypes (), size, result); }
MonoRecorder::MonoRecorder(bool fromFile) { is_truncated = is_processed = false; if ( fromFile ) { stamped_offset = 0; Read(false); assertid("OUT1"); filename = ReadString(); float t = ReadFloat(); if ( Datatype::PeakId() == "anim" ) { animation = new Animated<gmtl::Point3f>(); } else { setLocation(ReadVec()); animation = 0; } std::cout << this->toString(); } else { animation = 0; filename = ""; } has_samples = save_processed = false; tracks.push_back(new RecorderTrack()); }
void WrapMatrixCrossProduct (TomVM& vm) { if (ReadVec (vm, vm.GetIntParam (1), v1) < 0) return; CrossProduct (v1); ReturnMatrix (vm); }