本文整理匯總了C#中Mpir.NET.mpz_t.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# mpz_t.Dispose方法的具體用法?C# mpz_t.Dispose怎麽用?C# mpz_t.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mpir.NET.mpz_t
的用法示例。
在下文中一共展示了mpz_t.Dispose方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Divide
public mpz_t Divide(int x, out int remainder)
{
mpz_t quotient = new mpz_t();
if(x >= 0)
{
remainder = (int)mpir.mpz_tdiv_q_ui(quotient, this, (uint)x);
return quotient;
}
else
{
remainder = -(int)mpir.mpz_tdiv_q_ui(quotient, this, (uint)(-x));
mpz_t res = -quotient;
quotient.Dispose();
return res;
}
}
示例2: DivideExactly
public mpz_t DivideExactly(int x)
{
mpz_t z = new mpz_t();
mpir.mpz_divexact_ui(z, this, (uint)x);
if (x < 0) {
mpz_t res = -z;
z.Dispose();
return res;
} else {
return z;
}
}
示例3: mpz_t
public static mpz_t operator /(mpz_t x, int y)
{
if (y >= 0) {
mpz_t quotient = new mpz_t();
mpir.mpz_tdiv_q_ui(quotient, x, (uint)y);
return quotient;
} else {
mpz_t quotient = new mpz_t();
mpir.mpz_tdiv_q_ui(quotient, x, (uint)(-y));
mpz_t negQ = -quotient;
quotient.Dispose();
return negQ;
}
}
示例4: CompareTo
// TODO: Optimize by accessing the memory directly
public int CompareTo(ulong other)
{
mpz_t otherMpz = new mpz_t(other);
int ret = this.CompareTo(otherMpz);
otherMpz.Dispose();
return ret;
}
示例5: Binomial
public static mpz_t Binomial(int n, int k)
{
if(k < 0)
throw new ArgumentOutOfRangeException();
mpz_t z = new mpz_t();
if(n >= 0)
{
mpir.mpz_bin_uiui(z, (uint)n, (uint)k);
return z;
}
else
{
// Use the identity bin(n,k) = (-1)^k * bin(-n+k-1,k)
mpir.mpz_bin_uiui(z, (uint)(-n + k - 1), (uint)k);
if ((k & 1) != 0) {
mpz_t res = -z;
z.Dispose();
return res;
} else {
return z;
}
}
}