本文整理汇总了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;
}
}
}