// TODO fix me for clients static inline tree_node * getKeyNode(TREE_STATE_TYPE secret_index, unsigned char * perm_code, unsigned int perm_code_size, TREE_STATE_TYPE key_index, unsigned int flag){ TEST_SIGNAL_LOW; tree_edge * edges = getEdgesWithFunction(2, edgeFunc); if(edges == NULL){ return NULL; } edges[0].params = perm_code; edges[0].params_size = perm_code_size; edges[1].params = (unsigned char *)(&key_index); edges[1].params_size = TREE_STATE_SIZE; tree_node * p_res; if(!flag){ p_res = fillNodes(getPathFromCachedNodes(1, secret_index), edges+1, 1); if(NULL!= p_res){ TEST_SIGNAL_HIGH; return p_res; } } tree_node * p_nodes = getPathFromRoot(2); p_res = fillNodes(p_nodes, edges, 2); setCachedNode(secret_index, p_nodes+1); TEST_SIGNAL_HIGH; return p_res; }
SVMProblem(WindowFile &trainA, WindowFile &trainB) { l = countWins(trainA) + countWins(trainB); const qint32 samples = getNumSamples(trainA); assert(getNumSamples(trainB) == samples); y = new double[l]; x = new svm_node*[l]; x[0] = new svm_node[l*(samples+1)]; for(int i = 1; i < l; i++) { x[i] = &x[i-1][samples+1]; } float *buf = new float[samples]; int cur = 0; while(trainA.nextChannel()) { assert(trainA.getEventSamples() == samples); trainA.read((char*)buf, samples*sizeof(float)); fillNodes(x[cur], buf, samples); y[cur++] = 1.; } while(trainB.nextChannel()) { assert(trainB.getEventSamples() == samples); trainB.read((char*)buf, samples*sizeof(float)); fillNodes(x[cur], buf, samples); y[cur++] = -1.; } delete[] buf; assert(cur == l); }
void BulkAdapt::remote_edgeAdj_add(int remotePartID, adaptAdj adj, adaptAdj splitElem, int n1_idxl, int n2_idxl) { int n1 = get_node_from_idxl(n1_idxl, remotePartID), n2 = get_node_from_idxl(n2_idxl, remotePartID); // Find the relative nodes on the edge to be bisected int relNodes[4]; FEM_Elem &elems = meshPtr->elem[adj.elemType]; // elems is all local elements int *conn = elems.connFor(adj.localID); // conn points at elemID's ACTUAL data! fillNodes(relNodes, n1, n2, conn); // find which edgeID is bisected int edgeID = getEdgeID(relNodes[0], relNodes[1], 4, 3); addToAdaptAdj(meshPtr, adj, edgeID, splitElem); }
void BulkAdapt::remote_edgeAdj_replace(int remotePartID, adaptAdj elem, adaptAdj oldElem, adaptAdj newElem, int n1_idxl, int n2_idxl) { int n1 = get_node_from_idxl(n1_idxl, remotePartID), n2 = get_node_from_idxl(n2_idxl, remotePartID); // Find the relative nodes on the edge to be bisected int relNodes[4]; FEM_Elem &elems = meshPtr->elem[elem.elemType]; // elems is all local elements int *conn = elems.connFor(elem.localID); // conn points at elemID's ACTUAL data! fillNodes(relNodes, n1, n2, conn); // find which edgeID is bisected int edgeID = getEdgeID(relNodes[0], relNodes[1], 4, 3); replaceAdaptAdjOnEdge(meshPtr, elem, oldElem, newElem, edgeID); }
short search(){ printf("SEARCHING\n"); short nodes[4][3]={{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; short x = position[0]; short y = position[1]; //map[x][y+6][0] = Robot_GetIntersections(); //Kreuzung erhalten unsigned short intersection = mapIntersection(x, y + 6); fillNodes(nodes, intersection/16); //Knoten füllen fillUsed(nodes); //existierende Knoten auf "besucht" testen map[x][y+6][1] = 2; //Kreuzung auf "besucht" stellen if (findWay(nodes) == 1){ //Weg finden return 1; } return 0; }
/*! * \brief Handle permission request * * \param req Rest of request message after application name * \param req_size Size of this message * \param p_session Pointer to the corresponding application session * * \return Response message size */ unsigned int handlePermReq(unsigned char* req, unsigned int req_size, application_session * p_session){ if(req_size < 0 || p_session == NULL){ return 0; } unsigned int perm; if(SSCAN((const char*)req, "%u", &perm)==1){ /* Use the first active secret */ unsigned int secret_index = getFirstNotSetBit(); if(NO_BIT != secret_index){ TREE_STATE_TYPE perm_index = getExpectedState(secret_index,0); incExpectedState(secret_index, 0, 0); setBit(secret_index); setPermIndex(p_session->security_descriptor_id, perm_index); setPerm(p_session->security_descriptor_id, (RIGHT_TYPE)perm); setSecretIndex(p_session->security_descriptor_id, secret_index); memcpy(p_session->message, "permcode:", 9); p_session->message_size = 9+generatePermCode(p_session->security_descriptor_id, p_session->message+9, MAX_APPLICATION_MESSAGE_SIZE-9); /* Calculate Secret */ unsigned int depth = 2; tree_edge * edges = getEdges(depth - 1); edges[0].func = edgeFunc; edges[0].params = getPermCode(p_session->security_descriptor_id, &(edges[0].params_size)); tree_node * p_key_node = NULL; p_key_node = fillNodes(getPathFromRoot(depth), edges, depth); p_session->message[(p_session->message_size)++] = ':'; memcpy(p_session->message+p_session->message_size, &(p_key_node->block) , p_key_node->size); p_session->message_size += p_key_node->size; } else{ char * error_msg = "[ERROR] No inactive Secret"; memcpy(p_session->message, error_msg, strlen(error_msg)); p_session->message_size = strlen(error_msg); } return p_session->message_size; } return 0; }
void BulkAdapt::handle_split_3D(int remotePartID, int pos, int tableID, adaptAdj elem, RegionID lockRegionID, int n1_idxl, int n2_idxl, int n5_idxl) { int n1 = get_node_from_idxl(n1_idxl, remotePartID), n2 = get_node_from_idxl(n2_idxl, remotePartID), n5; if (is_node_in_idxl(n5_idxl, remotePartID)) { n5 = get_node_from_idxl(n5_idxl, remotePartID); } else { FEM_DataAttribute *coord = meshPtr->node.getCoord(); // all local coords double *n0co = (coord->getDouble()).getRow(n1); double *n1co = (coord->getDouble()).getRow(n2); double nodeCoords[9]; nodeCoords[0] = n0co[0]; nodeCoords[1] = n0co[1]; nodeCoords[2] = n0co[2]; nodeCoords[3] = n1co[0]; nodeCoords[4] = n1co[1]; nodeCoords[5] = n1co[2]; midpoint(&(nodeCoords[0]), &(nodeCoords[3]), 3, &(nodeCoords[6])); n5 = add_node(3, &(nodeCoords[6])); // Find the relative nodes on the edge to be bisected int relNodes[4]; FEM_Elem &elems = meshPtr->elem[elem.elemType]; // elems is all local elements int *conn = elems.connFor(elem.localID); // conn points at elemID's ACTUAL data! fillNodes(relNodes, n1, n2, conn); // find which edgeID is bisected int edgeID = getEdgeID(relNodes[0], relNodes[1], 4, 3); // find elements on edge to be bisected int numElemsToLock = 0; adaptAdj *elemsToLock; get_elemsToLock(elem, &elemsToLock, edgeID, &numElemsToLock); // find chunks that share the edge to be bisected int *chunks = (int *)malloc(numElemsToLock*sizeof(int)); int numParts=0; for (int i=0; i<numElemsToLock; i++) { chunks[i] = -1; int j; for (j=0; j<numParts; j++) { if (chunks[j] == elemsToLock[i].partID) { break; } } chunks[j] = elemsToLock[i].partID; if (j==numParts) numParts++; } if (numParts > 1) make_node_shared(n5, numParts, &chunks[0]); free(chunks); free(elemsToLock); } adaptAdj *splitElem = local_split_3D(elem, n1, n2, n5); shadowProxy[remotePartID].recv_split_3D(pos, tableID, elem, *splitElem); delete splitElem; }