mirror of
https://bitbucket.org/Mattrixwv/my-classes.git
synced 2026-02-04 03:12:27 -05:00
Updated so it is unnecessary to link gmp every time it is included
This commit is contained in:
@@ -29,8 +29,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
//This library is licensed under lgplv3
|
//This library is licensed under lgplv3
|
||||||
//You can find more information at gmplib.org
|
//You can find more information at gmplib.org
|
||||||
//IN ORDER TO USE THIS LIBRARY AS IS YOU MUST LINK BOTH libgmpxx AND libgmp TO COMPILE
|
//In order to use this functionality you must use the -DNEEDGMP flag in your compiler
|
||||||
|
//You must also link both libgmpxx and libgmp
|
||||||
|
#ifdef NEEDGMP
|
||||||
#include <gmpxx.h> //This is necessary for the getGmpFib function for numbers larger than a normal int can hold. It can be commented out if needed
|
#include <gmpxx.h> //This is necessary for the getGmpFib function for numbers larger than a normal int can hold. It can be commented out if needed
|
||||||
|
#endif //NEEDGMP
|
||||||
|
|
||||||
namespace mee{
|
namespace mee{
|
||||||
|
|
||||||
@@ -61,7 +64,11 @@ bool isFound(T num, std::vector<T> list);
|
|||||||
std::vector<std::string> getPermutations(std::string master, int num = 0);
|
std::vector<std::string> getPermutations(std::string master, int num = 0);
|
||||||
//These functions return the numth Fibonacci number
|
//These functions return the numth Fibonacci number
|
||||||
uint64_t getFib(uint64_t num);
|
uint64_t getFib(uint64_t num);
|
||||||
|
//In order to use this functionality you must use the -DNEEDGMP flag in your compiler
|
||||||
|
//You must also link both libgmpxx and libgmp
|
||||||
|
#ifdef NEEDGMP
|
||||||
mpz_class getMpzFib(uint64_t num);
|
mpz_class getMpzFib(uint64_t num);
|
||||||
|
#endif //NEEDGMP
|
||||||
//This is a function that performs a bubble sort on a vector
|
//This is a function that performs a bubble sort on a vector
|
||||||
template<class T>
|
template<class T>
|
||||||
bool bubbleSort(std::vector<T> nums);
|
bool bubbleSort(std::vector<T> nums);
|
||||||
@@ -271,6 +278,9 @@ uint64_t getFib(uint64_t num){
|
|||||||
return fib;
|
return fib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//In order to use this functionality you must use the -DNEEDGMP flag in your compiler
|
||||||
|
//You must also link both libgmpxx and libgmp
|
||||||
|
#ifdef NEEDGMP
|
||||||
mpz_class getMpzFib(uint64_t num){
|
mpz_class getMpzFib(uint64_t num){
|
||||||
//Make sure the number is within bounds
|
//Make sure the number is within bounds
|
||||||
if(num <= 0){
|
if(num <= 0){
|
||||||
@@ -292,6 +302,7 @@ mpz_class getMpzFib(uint64_t num){
|
|||||||
|
|
||||||
return tempNums[(num - 1) % 3]; //Return the answer
|
return tempNums[(num - 1) % 3]; //Return the answer
|
||||||
}
|
}
|
||||||
|
#endif //NEEDGMP
|
||||||
|
|
||||||
//This is a function that performs a bubble sort on a vector
|
//This is a function that performs a bubble sort on a vector
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
Reference in New Issue
Block a user