I want my function to return the type mpz_t, but I'm not sure how?
I've tried:
mpz_t MyFunction(mpz_t A, mpz_t B){}
But it didn't work, here is my code so far, I have bolded the parts of the code which are causing errors and added the errors in the comments:
Is there a way around this?Code:#include <iostream> #include <mpir.h> using namespace std; ???? A(mpz_t m, mpz_t n){ mpz_t mmo; //used to store the value of m, minus one mpz_t nmo; //used to store the value of n, minus one mpz_t one; //used to store the value 1 mpz_init(mmo); mpz_init(nmo); mpz_init(one); mpz_set_ui(one, 1); if(mpz_cmp_ui(m, 0) == 0){ mpz_add_ui(n, n, 1); return n; //error: return value type does not match the function type } if(mpz_cmp_ui(m, 0) > 0 && mpz_cmp_ui(n, 0) == 0){ mpz_sub_ui(mmo, m, 1); return A(mmo, one); } if(mpz_cmp_ui(m, 0) > 0 && mpz_cmp_ui(n, 0) > 0){ mpz_sub_ui(mmo, m, 1); mpz_sub_ui(nmo, n, 1); return A(mmo, A(m, nmo)); } } int main(){ mpz_t param1; mpz_init(param1); mpz_t param2; mpz_init(param2); mpz_set_ui(param1, 4); mpz_set_ui(param2, 2); mpz_out_str(stdout, 10, A(param1, param2)); return 0; }
Thank you![]()




Reply With Quote