ofxSymbolInstance parseInstance(ofxXmlSettings &xml) { ofxSymbolInstance i; if (xml.tagExists("matrix")) { // xml.pushTag("matrix"); // ofVec2f translation = ofVec2f(xml.getAttribute("Matrix", "tx", 0.0),xml.getAttribute("Matrix", "ty", 0.0)); // float scale = xml.getAttribute("Matrix", "a", 1.0); // float rotation = xml.getAttribute("Matrix", "c", 0.0); // xml.popTag(); // // i.mat.scale(scale, scale, 1.0); // i.mat.translate(translation); xml.pushTag("matrix"); i.mat = parseMatrix(xml); xml.popTag(); } if (xml.tagExists("transformationPoint")) { xml.pushTag("transformationPoint"); i.transformationPoint.push_back(ofVec2f(xml.getAttribute("Point", "x", 0.0),xml.getAttribute("Point", "y", 0.0))); xml.popTag(); } i.alphaMultiplier = 1.0; if (xml.tagExists("color")) { xml.pushTag("color"); i.alphaMultiplier = xml.getAttribute("Color", "alphaMultiplier", 1.0); xml.popTag(); } return i; }
unsigned long long TomKva_v5(char* aname, char* cname, int seconds) { FILE* afile = fopen(aname, "r"); FILE* cfile = fopen(cname, "r"); fm_count = 0; if (afile == NULL) { fprintf(stderr, "could not open file A\n"); exit(1); } if (cfile == NULL) { fprintf(stderr, "could not open file c\n"); exit(1); } _matrix* matA = parseMatrix(afile); _vector* vecC = parseVector(cfile); fclose(afile); fclose(cfile); Arena* arena = init_arena_basic(6, 6); if (seconds == 0) { /* Just run once for validation. */ // Uncomment when your function and variables exist... int result = fm_elim(arena, matA->rows, matA->columns, matA->cells, vecC->elements); free_up(matA,vecC); destroy_arena(arena); return result; //return 1; // return one, i.e. has a solution for now... } /* Tell operating system to call function DONE when an ALARM comes. */ signal(SIGALRM, done); alarm(seconds); /* Now loop until the alarm comes... */ proceed = true; while (proceed) { // Uncomment when your function and variables exist... // fm_elim(rows, cols, a, c); fm_elim(arena, matA->rows, matA->columns, matA->cells, vecC->elements); fm_count++; } // Clean up free_up(matA,vecC); destroy_arena(arena); return fm_count; }
bool KFormula13ContentHandler::startElement(const QString&, const QString& localName, const QString&, const QXmlAttributes& atts) { if (localName == "CONTENT" || localName == "FORMULASETTINGS" || localName == "FORMULA" || localName == "DENOMINATOR" || localName == "NUMERATOR") return true; parseMatrix(); QDomElement element; m_currentElement.appendChild(element); m_currentElement = element; if (localName == "SEQUENCE") m_currentElement.setTagName("mrow"); else if (localName == "BRACKET") { m_currentElement.setTagName("mfenced"); writeBracketAttributes(atts); } else if (localName == "SPACE") { m_currentElement.setTagName("mspace"); writeSpaceAttributes(atts); } else if (localName == "OVERLINE") { m_currentElement.setTagName("mover"); QDomElement tmp; tmp.setTagName("mo"); tmp.setNodeValue("‾"); m_currentElement.parentNode().appendChild(tmp); } else if (localName == "UNDERLINE") { m_currentElement.setTagName("munder"); QDomElement tmp; tmp.setTagName("mo"); tmp.setNodeValue("_"); m_currentElement.parentNode().appendChild(tmp); } else if (localName == "FRACTION") { m_currentElement.setTagName("mfrac"); if (atts.value("NOLINE").toInt() == 1) m_currentElement.setAttribute("linethickness", "0"); } else if (localName == "ROOT") m_currentElement.setTagName("msqrt"); else if (localName == "ROOTINDEX") { m_currentElement.setTagName("mrow"); m_currentElement.parentNode().toElement().setTagName("mroot"); } else if (localName == "MATRIX") { m_currentElement.setTagName("mtable"); int rows = atts.value("ROWS").toInt(); int cols = atts.value("COLUMNS").toInt(); m_matrixStack.push(QPair<int, int>(rows, cols)); } else if (localName == "MULTILINE") m_currentElement.setTagName("mtext"); else if (localName == "TEXT") { // m_currentElement. } return true; }
int main(){ Graph<int, int> g; FILE* fp = fopen("graph.db","r"); if(fp == NULL){ FATAL_LOG("fp is null"); } parseMatrix(g,fp); // debug<int, int>(g); g.show(); return 0; }
DataObject::DataObject(QString val) { mValue = val.trimmed(); if (isVector()) { mVector = parseVector(mValue); } else if (is4x4Matrix()) { m4x4Matrix = parse4x4Matrix(mValue); } else if (isMatrix()) { mMatrix = parseMatrix(mValue); } }
/* // Example Primitive { patchDef2 { "textures/darkmod/stone/brick/rough_big_blocks03" ( 5 3 0 0 0 ) ( ( ( 64 -88 108 0 0 ) ( 64 -88 184 0 -1.484375 ) ( 64 -88 184 0 -1.484375 ) ) ( ( 64 -88 184 1.484375 0 ) ( 64 -88 184 1.484375 -1.484375 ) ( 64 -88 184 1.484375 -1.484375 ) ) ( ( 112 -88 184 2.421875 0 ) ( 112 -88 184 2.421875 -1.484375 ) ( 112 -88 184 2.421875 -1.484375 ) ) ( ( 160 -88 184 3.359375 0 ) ( 160 -88 184 3.359375 -1.484375 ) ( 160 -88 184 3.359375 -1.484375 ) ) ( ( 160 -88 108 4.84375 0 ) ( 160 -88 184 4.84375 -1.484375 ) ( 160 -88 184 4.84375 -1.484375 ) ) ) } } */ scene::INodePtr PatchDef2Parser::parse(parser::DefTokeniser& tok) const { scene::INodePtr node = GlobalPatchCreator(DEF2).createPatch(); IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(node); assert(patchNode != NULL); IPatch& patch = patchNode->getPatch(); tok.assertNextToken("{"); // Parse shader patch.setShader(tok.nextToken()); // Parse parameters tok.assertNextToken("("); // parse matrix dimensions std::size_t cols = string::convert<std::size_t>(tok.nextToken()); std::size_t rows = string::convert<std::size_t>(tok.nextToken()); patch.setDims(cols, rows); // ignore contents/flags values tok.skipTokens(3); tok.assertNextToken(")"); // Parse Patch Matrix parseMatrix(tok, patch); // Parse Footer tok.assertNextToken("}"); tok.assertNextToken("}"); patch.controlPointsChanged(); return node; }
void KFormula13ContentHandler::parseMatrix() { if (m_matrixStack.isEmpty()) // if there is no matrix, return return; QDomElement element; int count = m_currentElement.childNodes().count(); if (m_currentElement.tagName() == "mtable" && count < m_matrixStack.top().first) { // check count < rowCount thought there should never be count == rowCount element.setTagName("mtr"); m_currentElement.appendChild(element); m_currentElement = element; } if (m_currentElement.tagName() == "mtr" && count < m_matrixStack.top().second) { // we need a new table entry so create one and set it as m_currentElement element.setTagName("mtd"); m_currentElement.appendChild(element); m_currentElement = element; } else if (m_currentElement.tagName() == "mtr" && count == m_matrixStack.top().second) { // the matrix has been parsed or the row is full and we need a new mtr, m_currentElement = m_currentElement.parentNode().toElement(); // move up parseMatrix(); // and reparse matrix with m_currentElement == mtable } }