{"id":20483411,"url":"https://github.com/styczynski/ipp-poly","last_synced_at":"2026-07-18T22:04:04.893Z","repository":{"id":79817382,"uuid":"91351134","full_name":"styczynski/ipp-poly","owner":"styczynski","description":":heavy_division_sign: Student's work (individual programistic project) at Warsaw University","archived":false,"fork":false,"pushed_at":"2018-02-13T16:41:13.000Z","size":3011,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T16:16:21.094Z","etag":null,"topics":["c","ipp-mimuw","warsaw-university"],"latest_commit_sha":null,"homepage":"http://styczynski.in/ipp-poly","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/styczynski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-15T15:03:34.000Z","updated_at":"2019-05-29T18:25:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"c896efa5-c53e-42f0-b0b4-ac4e342d6d97","html_url":"https://github.com/styczynski/ipp-poly","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/styczynski/ipp-poly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Fipp-poly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Fipp-poly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Fipp-poly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Fipp-poly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/styczynski","download_url":"https://codeload.github.com/styczynski/ipp-poly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styczynski%2Fipp-poly/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014107,"owners_count":26085463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","ipp-mimuw","warsaw-university"],"created_at":"2024-11-15T16:17:17.994Z","updated_at":"2025-10-13T07:34:17.761Z","avatar_url":"https://github.com/styczynski.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Made by Styczynsky Digital Systems][badge sts]][link styczynski]\n[![Travis](https://img.shields.io/travis/styczynski/ipp-poly.svg?style=flat-square)](https://travis-ci.org/styczynski/ipp-poly/builds)\n[![GitHub tag](https://img.shields.io/github/tag/styczynski/ipp-poly.svg?style=flat-square)](https://github.com/styczynski/ipp-poly)\n\n# :heavy_division_sign: ipp-poly \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [![Download][badge download]][link download latest]\n\nSee [Doxygen documentation](http://styczynski.in/ipp-poly)\n\n![Screenshot 1][screenshot 1]\n\n\n# Exercise\n\nThis project is based on exercise we had to do on `Warsaw University, Poland`\non the `Individual Programistic Project` subject.\n\n### Task\n\nThe exercise was to design and implement:\n* Provide dynamically-allocated lists implementation - *pre-exercise*\n\n* Polynomial handling library in pure C99 - *part no. 1*\n\n* Interactive calculator for that library - *part no. 2*\n\n* Implement additional functionality and provide basic unit tests - *part no. 3*\n\n### Project structure\n\nThe project provides:\n* library `src/poly.h` for handling polynomials\n\n* additional helper libraries like dynamically allocated arrays etc.\n\n* interactive calculator `src/calc_poly.c`\n\n* unit tests in `tests/`\n\n# Building\n\nTo build do the following:\n\n* Create release folder - `mkdir release`\n\n* Go to that folder - `cd release`\n\n* Generate makefiles - `cmake ..`\n\n* Build everything - `make`\n\n* Optionally run tests - `make test`\n\n* Optionally generate documentation (needs Doxygen to be installed) - `make doc`\n\n* Optionally clean everything - `make clean`\n\n# Polynomial library\n\nAll the documentation is provided in header files.\n\nThere you've got example usage of the library:\n\n```c\n  #include \"poly.h\"\n\n  int main(void) {\n\n    Poly p = PolyC(4);\n    // Create constant polynomial\n    // p(x) = 4\n\n    Poly q = PolyP( PolyC(1), 2 );\n    // Create polynomial that consists of\n    // variable square multiplied by\n    // coefficient 1\n    // q(x) = 1*x^2\n\n    // As you may see the coefficients that are placed\n    // next to variables may be other polynomials\n    // (polynomials from other variable)\n\n    Poly r = PolyP( PolyP( PolyC(1), 2 ), 3 );\n    // In this example\n    // r(x,y) = (1*y^2)*(x^3)\n\n    // Now you can do arithemtic operations on them\n    // for example addition:\n    Poly sum = PolyAdd(\u0026p, \u0026q);\n    // sum(x) = 4 + x^2\n    // If you are not sure what would happen if we sum\n    // q and r then we say that the result is\n    //\n    // q(x) + r(x,y) = 1*x^2 + (1*y^2)*(x^3)\n    // that is:\n    //   x^2 + (y^2)(x^3)\n    //\n\n    // Or evalue at specific point:\n    Poly rAtTwo = PolyAt(\u0026r, 2);\n    // Now we assume the first variable is equal to 2\n    // So we calculate r(x,y) for x-\u003e2\n    // rAtTwo = r(2,y) = (2^3)*y^2 = 8*y^2\n\n    // You can print them nicely:\n    PolyPrint(\u0026rAtTwo);\n    // ^ Do it yourself and see what the output is\n\n    // After everything we must free them all\n    PolyDestroy(\u0026p);\n    PolyDestroy(\u0026q);\n    PolyDestroy(\u0026r);\n    PolyDestroy(\u0026sum);\n    PolyDestroy(\u0026rAtTwo);\n\n  }\n```\n\n# Polynomial calculator\n\nThe calulator resides in `src/calc_poly.c`.\n\n  It reads data from stdin line by line and:\n\n1. If the line starts with lower/upper case letter then it's assumed\u003cbr\u003eto be an input command.\n\n2. Otherwise the input is parsed as a polynomial\u003cbr\u003eThe format of the polynomial is\u003cbr\u003e`(COEFF_1,EXP_1)+(COEFF_2,EXP_2)+...+(COEFF_N,EXP_N)`\u003cbr\u003eWhere pair `(COEFF_N,EXP_N)` represents single monomial `(COEFF_N)*x^(EXP_N)`\u003cbr\u003eThe coefficients can be numbers:\u003cbr\u003e`(1,3)+(2,4)` -\u003e `x^3 + 2x^4`\u003cbr\u003eOr polynomials (in this case they depend on other variable):\u003cbr\u003e`((1,3)+(2,4),2)+(1,3)` -\u003e `(x^3 + 2x^4)*y^2 + y^3`\u003cbr\u003ecan also contain monomials with the same exponent:\u003cbr\u003e`(1,2)+(1,2)` -\u003e 2x^2\u003cbr\u003eOr can be just numbers:\u003cbr\u003e`42` -\u003e constant polynomial 42\n\n\nAll the polynomials are parsed and placed on top of the stack.\nThen you can call one or more of the given operations\n\nto modify the stack contents:\n\n| Command    | Parameters | Required stack size | Description |\n|------------|------------|---------------------|-------------|\n|`ZERO`    |            |          0          | Pushes zero const polynomial onto stack  |\n|`IS_COEFF`|            |          1          | Checks if the stack top is a constant polynomial?  |\n|`IS_ZERO` |            |          1          | Checks if the stack top is a polynomial equal to 0?  |\n|`CLONE`   |            |          1          | Copies the polynomial on top of the stack and places it on the top. |\n|`ADD`     |            |          2          | Adds two polynomials from the top of the stack.\u003cbr\u003eThen puts the result on the stack top. |\n|`MUL`     |            |          2          | Multiplies two polynomials from the top of the stack.\u003cbr\u003eThen puts the result on the stack top.  |\n|`NEG`     |            |          1          | Changes the sign of the polynomial on the top of the stack.  |\n|`SUB`     |            |          2          | Substracts two polynomials from the top of the stack.\u003cbr\u003eThen puts the result on the stack top. |\n|`IS_EQ`   |            |          2          | Checks if two top-most polynomials are equal.  |\n|`DEG`     |            |          1          | Checks the degree of the top-most polynomial.\u003cbr\u003eDegree of the polynomial is a highest exponent of variable\u003cbr\u003eencountered in the polynomial (assuming all variables are the\u003cbr\u003esame one).\u003cbr\u003eE.g. degree(x^2 + yx^2) = 3  |\n|`DEG_BY`  |   *index*  |          1          | Checks the degree of the top-most polynomial\u003cbr\u003ewith respect to the given variable. Variables are indexed from 0\u003cbr\u003e(0 means the main variable of polynomial).\u003cbr\u003e\u003cbr\u003eE.g.\u003cbr\u003e`DegBy( ((1,2),3), 0 ) = DegBy( x^2 * y^3, 0 ) = 3`\u003cbr\u003e`DegBy( ((1,2),3), 1 ) = DegBy( x^2 * y^3, 1 ) = 2` |\n|`AT`      |   *value*  |          1          | Evaluates the top-most polynomial in specified point\u003cbr\u003eand put it into stack.\u003cbr\u003eThe polynomial is evalued for `MAIN_VARIABLE=[value]` where\u003cbr\u003e`MAIN_VARIABLE` is variable with index 0.\u003cbr\u003e\u003cbr\u003eE.g.\u003cbr\u003e`At( ((1,2),3), 0 ) = At( x^2 * y^3, 0 ) = 0`\u003cbr\u003e`At( (1,2), 2 ) = At( x^2, 2 ) = 4`\u003cbr\u003e\u003cbr\u003eThe result of this command is always a polynomial of degree one smaller\u003cbr\u003ethan the polynomial given. |\n|`PRINT`   |            |          1          | Prints the top-most polynomial. |\n|`POP`     |            |          1          | Pops the top-most polynomial from the stack. |\n|`POW`     |   *exp*    |          1          | Calculates the top-most polynomial power and push into the\u003cbr\u003estack. Obviously *exp* can be only a number! |\n|`COMPOSE` |  *count*   |       *count*+1     | Takes top-most polynomail from the stack.\u003cbr\u003e(We will call it P)\u003cbr\u003eThen take *count* polynomials from the stack (let's call them Q1, Q2 ...).\u003cbr\u003eThen we know that `P = C_1*x_1^E_1 + C_2*x_2^E_2 + ...`\u003cbr\u003eso we substitute\u003cbr\u003e`x_1 -\u003e Q1`\u003cbr\u003e`x_2 -\u003e Q2`\u003cbr\u003eetc.\u003cbr\u003eif the `x_n` has got no matching `QN` then we assume `x_n -\u003e 0`\u003cbr\u003e\u003cbr\u003eThen we put result of such substitution onto the stack. |\n|`DUMP`    |            |          0          | Prints the stack contents. |\n|`CLEAN`   |            |          0          | Clears the stack entinerely.  |\n|`EXIT`    |            |          0          | Force exits the calculator. |\n\n\n\n[screenshot 1]: https://raw.githubusercontent.com/styczynski/ipp-poly/master/static/screenshots/screenshot1.png\n\n[badge sts]: https://img.shields.io/badge/-styczynsky_digital_systems-blue.svg?style=flat-square\u0026logoWidth=20\u0026logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABYAAAAXCAYAAAAP6L%2BeAAAABmJLR0QA%2FwD%2FAP%2BgvaeTAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAB3RJTUUH4AgSEh0nVTTLngAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAm0lEQVQ4y2Pc%2Bkz2PwMNAAs2wVMzk4jSbJY%2BD6ccEwONACMsKIh1JSEgbXKeQdr4PO1cPPQMZiGkoC7bkCQD7%2Fx7znDn35AOClK9PEJSBbNYAJz999UGrOLocsM0KHB5EZ%2FXPxiVMDAwMDD8SP3DwJA6kFka5hJCQOBcDwMDAwPDm3%2FbGBj%2BbR8tNrFUTbiAB8tknHI7%2FuTilAMA9aAwA8miDpgAAAAASUVORK5CYII%3D\n\n[badge download]: https://img.shields.io/badge/-download_me!-green.svg?style=flat-square\u0026logoWidth=10\u0026logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABkAAAArCAYAAACNWyPFAAAABmJLR0QA%2FwD%2FAP%2BgvaeTAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAB3RJTUUH4AgTDjEFFOXcpQAAAM1JREFUWMPt2EsOgzAMBFDPJHD%2F80Jid1G1KpR8SqKu7C2QJzwWsoCZSWedb0Tvg5Q%2FlCOOOOKII4444ogjjvxW8bTjYtK57zNTSoCdNm5VBcmRhdua7SJpKaXhN2hmEmO0fd%2BnANXgl2WxbduGAVUFVbUY9rquPVARyDmDpJCktKBK66pACOE5Ia%2FhUlUhaTPm9xM4ZEJScs6YDXwFH0IYgq6Ay%2Bm6C5WAQyYXo9edUQ2oIr1Q5TPUh4iImJkAsMI1AO3O4u4fiV5AROQBGVB7Fu2akxMAAAAASUVORK5CYII%3D\n\n\n[link styczynski]: http://styczynski.in\n[link sts]: http://styczynski.in\n[link download latest]: https://github.com/styczynski/ipp-poly/archive/master.zip\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyczynski%2Fipp-poly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstyczynski%2Fipp-poly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyczynski%2Fipp-poly/lists"}