Eigen::VectorXd& BCIDataSet::getInstance(int i) { int epoch = 0, t0 = 0; getOffsets(i, epoch, t0); buildInstance(epoch, t0); return tempInstance; }
//}}}1 //{{{1 private functions void Scene::buildScene(Json::Value node) { Json::Value cam = node["camera"]; buildCamera(cam); Json::Value lights = node["lights"]; for(int i=0; i<lights.size(); i++) { buildLight(lights[i]); } Json::Value models = node["models"]; for(int i=0; i<models.size(); i++) { buildNode(models[i]); } if(node.isMember("instances")) { Json::Value instances = node["instances"]; for(int i=0; i<instances.size(); i++) { buildInstance(instances[i]); } } Json::Value anims = node["animations"]; for(int i=0; i<anims.size(); i++) { buildAnimation(anims[i]); } mat4 wm = LookAt(eye, at, up); setWorldMatrix(LookAt(eye, at, up)); printf("set init world matrix\n"); }
int BCIDataSet::evaluate(OpenANN::Learner& learner, int trials) { char characters[6][7] = { "ABCDEF", "GHIJKL", "MNOPQR", "STUVWX", "YZ1234", "56789_" }; Eigen::VectorXd y(1); int correct = 0; std::vector<char> predictions(readEpochs, 0); for(int e = 0; e < readEpochs; e++) { double score[12] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; int repetitions[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; std::vector<int>& offsets = instanceStart[e]; for(size_t i = 0; i < offsets.size(); i++) { int t0 = offsets[i]; buildInstance(e, t0); y = learner(tempInstance); int rowColCode = (int) stimulusCode(t0, e) - 1; if(repetitions[rowColCode] < trials) { score[rowColCode] += y(0); repetitions[rowColCode]++; } } int maxRow = -1, maxCol = -1; double maxRowScore = -std::numeric_limits<double>::max(), maxColScore = -std::numeric_limits<double>::max(); for(int i = 0; i < 6; i++) { if(score[i] > maxColScore) { maxCol = i; maxColScore = score[i]; } } for(int i = 6; i < 12; i++) { if(score[i] > maxRowScore) { maxRow = i - 6; maxRowScore = score[i]; } } char actual = targetChar[e]; predictions[e] = characters[maxRow][maxCol]; if(actual == predictions[e]) correct++; } return correct; }
int main(int , char** argv) { verbose = getenv("PEGASUS_TEST_VERBOSE"); const char* arg0 = argv[0]; CIMClient client; if (!connectToHost(client)) { cerr << "Connection to host failed. Terminating" << endl; exit(1); } Array<CIMObjectPath> paths; // // Create instances that will have specified test properties in them // that we can use for queries. We used the class // Test_CLITestProviderClass because it has a broad set of testable // properties. // String id1 = "PropertyOpTest1"; CIMInstance inst1 = buildInstance(client, id1); { setPropertyValue(inst1,"scalBool", CIMValue(true)); setPropertyValue(inst1,"scalUint8",CIMValue(Uint8(12))); setPropertyValue(inst1,"scalSint8",CIMValue(Sint8(12))); setPropertyValue(inst1,"scalUint16",CIMValue(Uint16(500))); setPropertyValue(inst1,"scalSint16",CIMValue(Sint16(500))); setPropertyValue(inst1,"scalUint32",CIMValue(Uint32(9999))); setPropertyValue(inst1,"scalSint32",CIMValue(Sint32(9999))); setPropertyValue(inst1,"scalUint64",CIMValue(Uint64(9999))); setPropertyValue(inst1,"scalSint64",CIMValue(Sint64(9999))); setPropertyValue(inst1,"scalString",CIMValue(String("String1"))); Array<Uint32> lArrayUint32; lArrayUint32.append(0); lArrayUint32.append(128); lArrayUint32.append(256); lArrayUint32.append(65536); lArrayUint32.append(4294967295); setPropertyValue(inst1,"arrayUint32",CIMValue(lArrayUint32)); } CIMObjectPath p1 = createInstance(client, inst1); paths.append(p1); String id2 = "PropertyOpTest2"; CIMInstance inst2 = buildInstance(client, id2); { setPropertyValue(inst2,"scalBool", CIMValue(false)); setPropertyValue(inst2,"scalUint8",CIMValue(Uint8(20))); setPropertyValue(inst2,"scalSint8",CIMValue(Sint8(8))); setPropertyValue(inst2,"scalUint16",CIMValue(Uint16(1000))); setPropertyValue(inst2,"scalSint16",CIMValue(Sint16(500))); setPropertyValue(inst2,"scalUint32",CIMValue(Uint32(7698))); setPropertyValue(inst2,"scalSint32",CIMValue(Sint32(9999))); setPropertyValue(inst2,"scalUint64",CIMValue(Uint64(9999))); setPropertyValue(inst2,"scalSint64",CIMValue(Sint64(9999))); setPropertyValue(inst2,"scalString",CIMValue(String("String2"))); Array<Uint32> lArrayUint32; lArrayUint32.append(0); lArrayUint32.append(128); lArrayUint32.append(256); lArrayUint32.append(165536); lArrayUint32.append(4294967295); lArrayUint32.append(876543); setPropertyValue(inst2,"arrayUint32",CIMValue(lArrayUint32)); } CIMObjectPath p2 = createInstance(client, inst2); paths.append(p2); // // Execute the query tests // testEnumerate(client, "scalBool = true", 2); testEnumerate(client,"scalUint32 = 7698", 1); testEnumerate(client, "scalString = 'String2'", 1); testEnumerate(client, "arrayUint32[5] = 876543", 1); testEnumerate(client, "ANY arrayUint32 = 876543", 1); testEnumerate(client, "scalString <> 'NoSuchString'", 3); testEnumerate(client, "scalString = 'String2'", 1); // the following are error tests testEnumerate(client, "scalUint32 = 'NotANumber'", 0, CIMStatusCode(15)); testEnumerate(client, "scalUint32 = 123a", 0, CIMStatusCode(15)); testEnumerate(client, "scalbool = 1234", 0, CIMStatusCode(15)); // Test associator CIMObjectPath assoc = CIMObjectPath("Test_CLITestProviderClass.Id=\"Mike\""); testAssociators(client, "scalBool = true",assoc, 1); testAssociators(client, "scalBool = false",assoc, 0); // Cheap test because only possible comparison is cimobject path // and that means building correct object path for the query // KS_TODO create a valid CIMObjectPath and test it. testReferences(client, "scalBool = false", assoc,0); for (Uint32 i = 0; i < paths.size(); i++) { deleteInstance(client,paths[i]); } cout << arg0 << " +++++ passed all tests."; }