本文整理汇总了Java中org.apfloat.ApfloatRuntimeException类的典型用法代码示例。如果您正苦于以下问题:Java ApfloatRuntimeException类的具体用法?Java ApfloatRuntimeException怎么用?Java ApfloatRuntimeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApfloatRuntimeException类属于org.apfloat包,在下文中一共展示了ApfloatRuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOperation
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
/**
* Get the calculation operation to execute.
*
* @param precision The precision to be used.
* @param radix The radix to be used.
*
* @return The calculation operation to execute.
*/
protected Operation<Apfloat> getOperation(long precision, int radix)
throws ApfloatRuntimeException
{
if (this.chudnovsky.getState())
{
return new Pi.ChudnovskyPiCalculator(precision, radix);
}
else if (this.ramanujan.getState())
{
return new Pi.RamanujanPiCalculator(precision, radix);
}
else if (this.gaussLegendre.getState())
{
return new Pi.GaussLegendrePiCalculator(precision, radix);
}
else
{
return new Pi.BorweinPiCalculator(precision, radix);
}
}
示例2: baseMultiplyAdd
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
/**
* Multiplication and addition in some base. Multiplies the data words
* of <code>src1</code> by <code>src3</code> and adds the result to the
* words in <code>src2</code>, and stores the result to <code>dst</code>.
* <code>src2</code> may be <code>null</code>, in which case it is ignored
* (the values are assumed to be zero).<p>
*
* Assumes that the result from the addition doesn't overflow the upper
* result word (to larger than the base). This is the case e.g. when using
* this method to perform an arbitrary precision multiplication.<p>
*
* Essentially calculates <code>dst[i] = src1[i] * src3 + src2[i]</code>.
*
* @param src1 First source data sequence.
* @param src2 Second source data sequence. Can be <code>null</code>, in which case it's ignored, or can be the same as <code>dst</code>.
* @param src3 Multiplicand. All elements of <code>src1</code> are multiplied by this value.
* @param carry Input carry word. This is added to the first (rightmost) word in the accessed sequence.
* @param dst Destination data sequence.
* @param size Number of elements to process.
*
* @return Overflow carry word. Propagated carry word from the multiplication and addition of the last (leftmost) word in the accessed sequence.
*/
public float baseMultiplyAdd(DataStorage.Iterator src1, DataStorage.Iterator src2, float src3, float carry, DataStorage.Iterator dst, long size)
throws ApfloatRuntimeException
{
assert (src1 != src2);
assert (src1 != dst);
double base = BASE[this.radix];
for (long i = 0; i < size; i++)
{
double tmp = (double) src1.getFloat() * (double) src3 +
(double) (src2 == null ? 0 : src2.getFloat()) + (double) carry;
carry = (float) (int) (tmp / base);
dst.setFloat((float) (tmp - (double) carry * base)); // = tmp % base
src1.next();
if (src2 != null && src2 != dst) src2.next();
dst.next();
}
return carry;
}
示例3: getOperation
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
@Override
protected Operation<Apfloat> getOperation(long precision, int radix)
throws ApfloatRuntimeException
{
ApfloatContext ctx = ApfloatContext.getContext();
int numberOfProcessors = Integer.parseInt(this.threadsField.getText());
ctx.setNumberOfProcessors(numberOfProcessors);
ctx.setExecutorService(ApfloatContext.getDefaultExecutorService());
Operation<Apfloat> operation = super.getOperation(precision, radix);
if (operation instanceof Pi.ChudnovskyPiCalculator)
{
operation = new PiParallel.ParallelChudnovskyPiCalculator(precision, radix);
}
else if (operation instanceof Pi.RamanujanPiCalculator)
{
operation = new PiParallel.ParallelRamanujanPiCalculator(precision, radix);
}
return operation;
}
示例4: getLeastSignificantWord
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
private rawtype getLeastSignificantWord(long index, rawtype word)
throws ApfloatRuntimeException
{
if (this.precision == Apfloat.INFINITE)
{
return word;
}
// Total digits including the specified index
long digits = getInitialDigits() + index * BASE_DIGITS[this.radix];
if (this.precision >= digits)
{
return word;
}
// Assert that the second array access will not be out of bounds
rawtype divisor = MINIMUM_FOR_DIGITS[this.radix][(int) (digits - this.precision)];
return (rawtype) (long) (word / divisor) * divisor;
}
示例5: p
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
public Apfloat p(long n)
throws ApfloatRuntimeException
{
Apfloat v;
if (n == 0)
{
v = this.ONE;
}
else
{
Apfloat f = new Apfloat(n, Apfloat.INFINITE, this.radix),
sixf = this.SIX.multiply(f);
v = sixf.subtract(this.ONE).multiply(this.TWO.multiply(f).subtract(this.ONE)).multiply(sixf.subtract(this.FIVE));
}
return v;
}
示例6: q
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
public Apfloat q(long n)
throws ApfloatRuntimeException
{
Apfloat v;
if (n == 0)
{
v = this.ONE;
}
else
{
Apfloat f = new Apfloat(n, Apfloat.INFINITE, this.radix);
v = this.J.multiply(f.multiply(f).multiply(f));
}
return v;
}
示例7: run
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
/**
* Execute an operation and display some additional information.
* The return value of the operation is written to {@link #out}.
*
* @param precision The precision to be used.
* @param radix The radix to be used.
* @param operation The operation to execute.
*
* @exception IOException In case writing the output fails.
*/
public static void run(long precision, int radix, Operation<Apfloat> operation)
throws IOException, ApfloatRuntimeException
{
dump();
Pi.err.println("Calculating pi to " + precision + " radix-" + radix + " digits");
long time = System.currentTimeMillis();
Apfloat pi = operation.execute();
time = System.currentTimeMillis() - time;
pi.writeTo(Pi.out, true);
Pi.out.println();
Pi.err.println("Total elapsed time " + time / 1000.0 + " seconds");
}
示例8: getLeadingZeros
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
private static long getLeadingZeros(DataStorage dataStorage, long index)
throws ApfloatRuntimeException
{
long count = 0;
DataStorage.Iterator iterator = dataStorage.iterator(DataStorage.READ, index, dataStorage.getSize());
while (iterator.hasNext())
{
if (iterator.getRawtype() != 0)
{
iterator.close();
break;
}
iterator.next();
count++;
}
return count;
}
示例9: setReadOnly
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
/**
* Sets this data storage as read-only.
* All existing sub-sequences (recursively) of this data storage
* are set to read-only as well.
*/
public final void setReadOnly()
throws ApfloatRuntimeException
{
if (isReadOnly())
{
return;
}
if (!isSubsequenced())
{
this.length = implGetSize();
}
if (this.originalDataStorage == null)
{
this.isReadOnly = true;
}
else
{
this.originalDataStorage.setReadOnly();
}
}
示例10: inverseTransform
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
public void inverseTransform(DataStorage dataStorage, int modulus, long totalTransformLength)
throws ApfloatRuntimeException
{
long length = dataStorage.getSize(); // Transform length n
if (Math.max(length, totalTransformLength) > MAX_TRANSFORM_LENGTH)
{
throw new TransformLengthExceededException("Maximum transform length exceeded: " + Math.max(length, totalTransformLength) + " > " + MAX_TRANSFORM_LENGTH);
}
else if (length > Integer.MAX_VALUE)
{
throw new ApfloatInternalException("Maximum array length exceeded: " + length);
}
setModulus(MODULUS[modulus]); // Modulus
rawtype[] wTable = RawtypeWTables.getInverseWTable(modulus, (int) length);
ArrayAccess arrayAccess = dataStorage.getArray(DataStorage.READ_WRITE, 0, (int) length);
inverseTableFNT(arrayAccess, wTable, null);
divideElements(arrayAccess, (rawtype) totalTransformLength);
arrayAccess.close();
}
示例11: subsequence
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
/**
* Get a subsequence of this data storage.
*
* @param offset The subsequence starting position.
* @param length The subsequence length.
*
* @return Data storage that represents the specified part of this data storage.
*
* @exception IllegalArgumentException If the requested subsequence is out of range.
*/
public final DataStorage subsequence(long offset, long length)
throws IllegalArgumentException, ApfloatRuntimeException
{
if (offset < 0 || length <= 0 || offset + length < 0 ||
offset + length > getSize())
{
throw new IllegalArgumentException("Requested subsequence out of range: offset=" + offset + ", length=" + length + ", available=" + getSize());
}
setSubsequenced();
if (offset == 0 && length == getSize())
{
// Full contents of the data set; not actually a subsequence
return this;
}
return implSubsequence(offset, length);
}
示例12: createCachedDataStorage
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
public DataStorage createCachedDataStorage(long size)
throws ApfloatRuntimeException
{
ApfloatContext ctx = ApfloatContext.getContext();
// Sizes are in bytes
if (size <= ctx.getMaxMemoryBlockSize() && size <= getMaxCachedSize())
{
// Use memory data storage if it can fit in memory
return createCachedDataStorage();
}
else
{
// If it can't fit in memory then still have to use disk data storage
return createNonCachedDataStorage();
}
}
示例13: findMismatch
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
private long findMismatch(DataStorage.Iterator thisIterator, DataStorage.Iterator thatIterator, long size)
throws ApfloatRuntimeException
{
for (long index = 0; index < size; index++)
{
rawtype thisValue = thisIterator.getRawtype(),
thatValue = thatIterator.getRawtype();
if (thisValue != thatValue)
{
return index;
}
thisIterator.next();
thatIterator.next();
}
// All searched words matched exactly
return -1;
}
示例14: next
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
@Override
public void next()
throws IllegalStateException, ApfloatRuntimeException
{
checkLength();
assert (this.remaining > 0);
checkAvailable();
this.offset += getIncrement();
this.remaining--;
if (this.remaining == 0)
{
close();
}
super.next();
}
示例15: getTrailingZeros
import org.apfloat.ApfloatRuntimeException; //导入依赖的package包/类
private static long getTrailingZeros(DataStorage dataStorage, long index)
throws ApfloatRuntimeException
{
long count = 0;
DataStorage.Iterator iterator = dataStorage.iterator(DataStorage.READ, index, 0);
while (iterator.hasNext())
{
if (iterator.getRawtype() != 0)
{
iterator.close();
break;
}
iterator.next();
count++;
}
return count;
}