OpenShot Audio Library | OpenShotAudio 0.4.0
|
#include <juce_BigInteger.h>
Public Member Functions | |
BigInteger () | |
BigInteger (uint32 value) | |
BigInteger (int32 value) | |
BigInteger (int64 value) | |
BigInteger (const BigInteger &) | |
BigInteger (BigInteger &&) noexcept | |
BigInteger & | operator= (BigInteger &&) noexcept |
~BigInteger () | |
BigInteger & | operator= (const BigInteger &) |
void | swapWith (BigInteger &) noexcept |
bool | operator[] (int bit) const noexcept |
bool | isZero () const noexcept |
bool | isOne () const noexcept |
int | toInteger () const noexcept |
int64 | toInt64 () const noexcept |
BigInteger & | clear () noexcept |
BigInteger & | clearBit (int bitNumber) noexcept |
BigInteger & | setBit (int bitNumber) |
BigInteger & | setBit (int bitNumber, bool shouldBeSet) |
BigInteger & | setRange (int startBit, int numBits, bool shouldBeSet) |
BigInteger & | insertBit (int bitNumber, bool shouldBeSet) |
BigInteger | getBitRange (int startBit, int numBits) const |
uint32 | getBitRangeAsInt (int startBit, int numBits) const noexcept |
BigInteger & | setBitRangeAsInt (int startBit, int numBits, uint32 valueToSet) |
BigInteger & | shiftBits (int howManyBitsLeft, int startBit) |
int | countNumberOfSetBits () const noexcept |
int | findNextSetBit (int startIndex) const noexcept |
int | findNextClearBit (int startIndex) const noexcept |
int | getHighestBit () const noexcept |
bool | isNegative () const noexcept |
void | setNegative (bool shouldBeNegative) noexcept |
void | negate () noexcept |
BigInteger & | operator+= (const BigInteger &) |
BigInteger & | operator-= (const BigInteger &) |
BigInteger & | operator*= (const BigInteger &) |
BigInteger & | operator/= (const BigInteger &) |
BigInteger & | operator|= (const BigInteger &) |
BigInteger & | operator&= (const BigInteger &) |
BigInteger & | operator^= (const BigInteger &) |
BigInteger & | operator%= (const BigInteger &) |
BigInteger & | operator<<= (int numBitsToShift) |
BigInteger & | operator>>= (int numBitsToShift) |
BigInteger & | operator++ () |
BigInteger & | operator-- () |
BigInteger | operator++ (int) |
BigInteger | operator-- (int) |
BigInteger | operator- () const |
BigInteger | operator+ (const BigInteger &) const |
BigInteger | operator- (const BigInteger &) const |
BigInteger | operator* (const BigInteger &) const |
BigInteger | operator/ (const BigInteger &) const |
BigInteger | operator| (const BigInteger &) const |
BigInteger | operator& (const BigInteger &) const |
BigInteger | operator^ (const BigInteger &) const |
BigInteger | operator% (const BigInteger &) const |
BigInteger | operator<< (int numBitsToShift) const |
BigInteger | operator>> (int numBitsToShift) const |
bool | operator== (const BigInteger &) const noexcept |
bool | operator!= (const BigInteger &) const noexcept |
bool | operator< (const BigInteger &) const noexcept |
bool | operator<= (const BigInteger &) const noexcept |
bool | operator> (const BigInteger &) const noexcept |
bool | operator>= (const BigInteger &) const noexcept |
int | compare (const BigInteger &other) const noexcept |
int | compareAbsolute (const BigInteger &other) const noexcept |
void | divideBy (const BigInteger &divisor, BigInteger &remainder) |
BigInteger | findGreatestCommonDivisor (BigInteger other) const |
void | exponentModulo (const BigInteger &exponent, const BigInteger &modulus) |
void | inverseModulo (const BigInteger &modulus) |
void | montgomeryMultiplication (const BigInteger &other, const BigInteger &modulus, const BigInteger &modulusp, int k) |
void | extendedEuclidean (const BigInteger &a, const BigInteger &b, BigInteger &xOut, BigInteger &yOut) |
String | toString (int base, int minimumNumCharacters=1) const |
void | parseString (StringRef text, int base) |
MemoryBlock | toMemoryBlock () const |
void | loadFromMemoryBlock (const MemoryBlock &data) |
An arbitrarily large integer class.
A BigInteger can be used in a similar way to a normal integer, but has no size limit (except for memory and performance constraints).
Negative values are possible, but the value isn't stored as 2s-complement, so be careful if you use negative values and look at the values of individual bits.
Definition at line 38 of file juce_BigInteger.h.
juce::BigInteger::BigInteger | ( | ) |
Creates an empty BigInteger
Definition at line 54 of file juce_BigInteger.cpp.
juce::BigInteger::BigInteger | ( | uint32 | value | ) |
Creates a BigInteger containing an integer value in its low bits. The low 32 bits of the number are initialised with this value.
Definition at line 74 of file juce_BigInteger.cpp.
juce::BigInteger::BigInteger | ( | int32 | value | ) |
Creates a BigInteger containing an integer value in its low bits. The low 32 bits of the number are initialised with the absolute value passed in, and its sign is set to reflect the sign of the number.
Definition at line 61 of file juce_BigInteger.cpp.
juce::BigInteger::BigInteger | ( | int64 | value | ) |
Creates a BigInteger containing an integer value in its low bits. The low 64 bits of the number are initialised with the absolute value passed in, and its sign is set to reflect the sign of the number.
Definition at line 86 of file juce_BigInteger.cpp.
juce::BigInteger::BigInteger | ( | const BigInteger & | other | ) |
Creates a copy of another BigInteger.
Definition at line 103 of file juce_BigInteger.cpp.
|
noexcept |
Move constructor
Definition at line 114 of file juce_BigInteger.cpp.
|
default |
Destructor.
|
noexcept |
Resets the value to 0.
Definition at line 281 of file juce_BigInteger.cpp.
Referenced by juce::Synthesiser::allNotesOff(), divideBy(), extendedEuclidean(), inverseModulo(), and parseString().
|
noexcept |
Clears a particular bit in the number.
Definition at line 320 of file juce_BigInteger.cpp.
Referenced by juce::Synthesiser::handleSustainPedal(), and setBit().
|
noexcept |
Does a signed comparison of two BigIntegers.
Return values are:
Definition at line 743 of file juce_BigInteger.cpp.
Referenced by montgomeryMultiplication().
|
noexcept |
Compares the magnitudes of two BigIntegers, ignoring their signs.
Return values are:
Definition at line 756 of file juce_BigInteger.cpp.
Referenced by divideBy(), exponentModulo(), extendedEuclidean(), and inverseModulo().
|
noexcept |
Returns the total number of set bits in the value.
Definition at line 380 of file juce_BigInteger.cpp.
Referenced by juce::AudioDeviceManager::setAudioDeviceSetup().
void juce::BigInteger::divideBy | ( | const BigInteger & | divisor, |
BigInteger & | remainder | ||
) |
Divides this value by another one and returns the remainder.
This number is divided by other, leaving the quotient in this number, with the remainder being copied to the other BigInteger passed in.
Definition at line 578 of file juce_BigInteger.cpp.
Referenced by divideBy(), findGreatestCommonDivisor(), inverseModulo(), and toString().
void juce::BigInteger::exponentModulo | ( | const BigInteger & | exponent, |
const BigInteger & | modulus | ||
) |
Performs a combined exponent and modulo operation. This BigInteger's value becomes (this ^ exponent) % modulus.
Definition at line 919 of file juce_BigInteger.cpp.
void juce::BigInteger::extendedEuclidean | ( | const BigInteger & | a, |
const BigInteger & | b, | ||
BigInteger & | xOut, | ||
BigInteger & | yOut | ||
) |
Performs the Extended Euclidean algorithm. This method will set the xOut and yOut arguments such that (a * xOut) - (b * yOut) = GCD (a, b). On return, this object is left containing the value of the GCD.
Definition at line 1005 of file juce_BigInteger.cpp.
Referenced by exponentModulo().
BigInteger juce::BigInteger::findGreatestCommonDivisor | ( | BigInteger | other | ) | const |
Returns the largest value that will divide both this value and the argument.
Definition at line 900 of file juce_BigInteger.cpp.
Referenced by inverseModulo().
|
noexcept |
Looks for the index of the next clear bit after a given starting point.
This searches from startIndex (inclusive) upwards for the first clear bit, and returns its index.
Definition at line 413 of file juce_BigInteger.cpp.
|
noexcept |
Looks for the index of the next set bit after a given starting point.
This searches from startIndex (inclusive) upwards for the first set bit, and returns its index. If no set bits are found, it returns -1.
Definition at line 402 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::getBitRange | ( | int | startBit, |
int | numBits | ||
) | const |
Returns a range of bits as a new BigInteger.
e.g. getBitRangeAsInt (0, 64) would return the lowest 64 bits.
Definition at line 219 of file juce_BigInteger.cpp.
|
noexcept |
Returns a range of bits as an integer value.
e.g. getBitRangeAsInt (0, 32) would return the lowest 32 bits.
Asking for more than 32 bits isn't allowed (obviously) - for that, use getBitRange().
Definition at line 237 of file juce_BigInteger.cpp.
Referenced by getBitRange(), and toString().
|
noexcept |
Returns the index of the highest set bit in the number. If the value is zero, this will return -1.
Definition at line 391 of file juce_BigInteger.cpp.
Referenced by BigInteger(), divideBy(), exponentModulo(), findGreatestCommonDivisor(), getBitRange(), isOne(), isZero(), loadFromMemoryBlock(), juce::Random::nextLargeNumber(), and toMemoryBlock().
BigInteger & juce::BigInteger::insertBit | ( | int | bitNumber, |
bool | shouldBeSet | ||
) |
Inserts a bit an a given position, shifting up any bits above it.
Definition at line 341 of file juce_BigInteger.cpp.
void juce::BigInteger::inverseModulo | ( | const BigInteger & | modulus | ) |
Performs an inverse modulo on the value. i.e. the result is (this ^ -1) mod (modulus).
Definition at line 1042 of file juce_BigInteger.cpp.
|
noexcept |
Returns true if the value is less than zero.
Definition at line 361 of file juce_BigInteger.cpp.
Referenced by divideBy(), inverseModulo(), montgomeryMultiplication(), and toString().
|
noexcept |
Returns true if the value is 1.
Definition at line 356 of file juce_BigInteger.cpp.
Referenced by exponentModulo(), and inverseModulo().
|
noexcept |
Returns true if no bits are set.
Definition at line 351 of file juce_BigInteger.cpp.
Referenced by findGreatestCommonDivisor(), isNegative(), negate(), juce::AudioDeviceManager::setAudioDeviceSetup(), and toString().
void juce::BigInteger::loadFromMemoryBlock | ( | const MemoryBlock & | data | ) |
Converts a block of raw data into a number.
The data is arranged as little-endian, so the first byte of data is the low 8 bits of the number, and so on.
Definition at line 1205 of file juce_BigInteger.cpp.
void juce::BigInteger::montgomeryMultiplication | ( | const BigInteger & | other, |
const BigInteger & | modulus, | ||
const BigInteger & | modulusp, | ||
int | k | ||
) |
Performs the Montgomery Multiplication with modulo. This object is left containing the result value: ((this * other) * R1) % modulus. To get this result, we need modulus, modulusp and k such as R = 2^k, with modulus * modulusp - R * R1 = GCD(modulus, R) = 1
Definition at line 985 of file juce_BigInteger.cpp.
Referenced by exponentModulo().
|
noexcept |
Inverts the sign of the number.
Definition at line 371 of file juce_BigInteger.cpp.
Referenced by extendedEuclidean().
|
noexcept |
Definition at line 775 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator% | ( | const BigInteger & | other | ) | const |
Definition at line 736 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator%= | ( | const BigInteger & | divisor | ) |
Definition at line 715 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator& | ( | const BigInteger & | other | ) | const |
Definition at line 734 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator&= | ( | const BigInteger & | other | ) |
Definition at line 659 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator* | ( | const BigInteger & | other | ) | const |
Definition at line 731 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator*= | ( | const BigInteger & | other | ) |
Definition at line 533 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator+ | ( | const BigInteger & | other | ) | const |
Definition at line 729 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator++ | ( | ) |
Definition at line 723 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator++ | ( | int | ) |
Definition at line 725 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator+= | ( | const BigInteger & | other | ) |
Definition at line 425 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator- | ( | ) | const |
Definition at line 728 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator- | ( | const BigInteger & | other | ) | const |
Definition at line 730 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator-- | ( | ) |
Definition at line 724 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator-- | ( | int | ) |
Definition at line 726 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator-= | ( | const BigInteger & | other | ) |
Definition at line 476 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator/ | ( | const BigInteger & | other | ) | const |
Definition at line 732 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator/= | ( | const BigInteger & | other | ) |
Definition at line 625 of file juce_BigInteger.cpp.
|
noexcept |
Definition at line 776 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator<< | ( | int | numBitsToShift | ) | const |
Definition at line 737 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator<<= | ( | int | numBitsToShift | ) |
Definition at line 739 of file juce_BigInteger.cpp.
|
noexcept |
Definition at line 777 of file juce_BigInteger.cpp.
|
noexcept |
Move assignment operator
Definition at line 123 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator= | ( | const BigInteger & | other | ) |
Copies another BigInteger onto this one.
Definition at line 144 of file juce_BigInteger.cpp.
|
noexcept |
Definition at line 774 of file juce_BigInteger.cpp.
|
noexcept |
Definition at line 778 of file juce_BigInteger.cpp.
|
noexcept |
Definition at line 779 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator>> | ( | int | numBitsToShift | ) | const |
Definition at line 738 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator>>= | ( | int | numBitsToShift | ) |
Definition at line 740 of file juce_BigInteger.cpp.
|
noexcept |
Returns the value of a specified bit in the number. If the index is out-of-range, the result will be false.
Definition at line 200 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator^ | ( | const BigInteger & | other | ) | const |
Definition at line 735 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator^= | ( | const BigInteger & | other | ) |
Definition at line 685 of file juce_BigInteger.cpp.
BigInteger juce::BigInteger::operator| | ( | const BigInteger & | other | ) | const |
Definition at line 733 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::operator|= | ( | const BigInteger & | other | ) |
Definition at line 632 of file juce_BigInteger.cpp.
void juce::BigInteger::parseString | ( | StringRef | text, |
int | base | ||
) |
Reads the numeric value from a string.
Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex). Any invalid characters will be ignored.
Definition at line 1145 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::setBit | ( | int | bitNumber | ) |
Sets a specified bit to 1.
Definition at line 294 of file juce_BigInteger.cpp.
Referenced by juce::MixerAudioSource::addInputSource(), divideBy(), juce::Random::fillBitsRandomly(), juce::Synthesiser::handleSustainPedal(), insertBit(), setBit(), setBitRangeAsInt(), and setRange().
BigInteger & juce::BigInteger::setBit | ( | int | bitNumber, |
bool | shouldBeSet | ||
) |
Sets or clears a specified bit.
Definition at line 310 of file juce_BigInteger.cpp.
BigInteger & juce::BigInteger::setBitRangeAsInt | ( | int | startBit, |
int | numBits, | ||
uint32 | valueToSet | ||
) |
Sets a range of bits to an integer value.
Copies the given integer onto a range of bits, starting at startBit, and using up to numBits of the available bits.
Definition at line 263 of file juce_BigInteger.cpp.
Referenced by juce::Random::fillBitsRandomly(), and loadFromMemoryBlock().
|
noexcept |
Changes the sign of the number to be positive or negative.
Definition at line 366 of file juce_BigInteger.cpp.
Referenced by divideBy(), and parseString().
BigInteger & juce::BigInteger::setRange | ( | int | startBit, |
int | numBits, | ||
bool | shouldBeSet | ||
) |
Sets a range of bits to be either on or off.
startBit | the first bit to change |
numBits | the number of bits to change |
shouldBeSet | whether to turn these bits on or off |
Definition at line 333 of file juce_BigInteger.cpp.
Referenced by juce::AudioChannelSet::ambisonic(), juce::AudioChannelSet::discreteChannels(), and montgomeryMultiplication().
BigInteger & juce::BigInteger::shiftBits | ( | int | howManyBitsLeft, |
int | startBit | ||
) |
Shifts a section of bits left or right.
howManyBitsLeft | how far to move the bits (+ve numbers shift it left, -ve numbers shift it right). |
startBit | the first bit to affect - if this is > 0, only bits above that index will be affected. |
Definition at line 873 of file juce_BigInteger.cpp.
Referenced by insertBit(), and juce::MixerAudioSource::removeInputSource().
|
noexcept |
Swaps the internal contents of this with another object.
Definition at line 133 of file juce_BigInteger.cpp.
Referenced by divideBy(), exponentModulo(), extendedEuclidean(), findGreatestCommonDivisor(), and inverseModulo().
|
noexcept |
Attempts to get the lowest 64 bits of the value as an integer. If the value is bigger than the integer limits, this will return only the lower bits.
Definition at line 212 of file juce_BigInteger.cpp.
|
noexcept |
Attempts to get the lowest 32 bits of the value as an integer. If the value is bigger than the integer limits, this will return only the lower bits.
Definition at line 206 of file juce_BigInteger.cpp.
MemoryBlock juce::BigInteger::toMemoryBlock | ( | ) | const |
Turns the number into a block of binary data.
The data is arranged as little-endian, so the first byte of data is the low 8 bits of the number, and so on.
Definition at line 1193 of file juce_BigInteger.cpp.
String juce::BigInteger::toString | ( | int | base, |
int | minimumNumCharacters = 1 |
||
) | const |
Converts the number to a string.
Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex). If minimumNumCharacters is greater than 0, the returned string will be padded with leading zeros to reach at least that length.
Definition at line 1098 of file juce_BigInteger.cpp.