本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT属性的具体用法?Java LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT怎么用?Java LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ArrayFieldVector
/**
* Construct a vector by appending one vector to another vector.
*
* @param field Field to which the elements belong.
* @param v1 First vector (will be put in front of the new vector).
* @param v2 Second vector (will be put at back of the new vector).
* @throws NullArgumentException if {@code v1} or {@code v2} is
* {@code null}.
* @throws ZeroException if both arrays are empty.
* @see #ArrayFieldVector(FieldElement[], FieldElement[])
*/
public ArrayFieldVector(Field<T> field, T[] v1, T[] v2)
throws NullArgumentException, ZeroException {
MathUtils.checkNotNull(v1);
MathUtils.checkNotNull(v2);
if (v1.length + v2.length == 0) {
throw new ZeroException(LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT);
}
data = MathArrays.buildArray(field, v1.length + v2.length);
System.arraycopy(v1, 0, data, 0, v1.length);
System.arraycopy(v2, 0, data, v1.length, v2.length);
this.field = field;
}
示例2: createFieldVector
/**
* Creates a {@link FieldVector} using the data from the input array.
*
* @param <T> the type of the field elements
* @param data the input data
* @return a data.length FieldVector
* @throws NoDataException if {@code data} is empty.
* @throws NullArgumentException if {@code data} is {@code null}.
* @throws ZeroException if {@code data} has 0 elements
*/
public static <T extends FieldElement<T>> FieldVector<T> createFieldVector(final T[] data)
throws NoDataException, NullArgumentException, ZeroException {
if (data == null) {
throw new NullArgumentException();
}
if (data.length == 0) {
throw new ZeroException(LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT);
}
return new ArrayFieldVector<T>(data[0].getField(), data, true);
}
示例3: ArrayFieldVector
/**
* Construct a vector from an array, copying the input array.
* This constructor needs a non-empty {@code d} array to retrieve
* the field from its first element. This implies it cannot build
* 0 length vectors. To build vectors from any size, one should
* use the {@link #ArrayFieldVector(Field, FieldElement[])} constructor.
*
* @param d Array.
* @throws NullArgumentException if {@code d} is {@code null}.
* @throws ZeroException if {@code d} is empty.
* @see #ArrayFieldVector(Field, FieldElement[])
*/
public ArrayFieldVector(T[] d) {
if (d == null) {
throw new NullArgumentException();
}
try {
field = d[0].getField();
data = d.clone();
} catch (ArrayIndexOutOfBoundsException e) {
throw new ZeroException(LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT);
}
}
示例4: createFieldVector
/**
* Creates a {@link FieldVector} using the data from the input array.
*
* @param <T> the type of the field elements
* @param data the input data
* @return a data.length FieldVector
* @throws NoDataException if {@code data} is empty.
* @throws NullArgumentException if {@code data} is {@code null}.
* @throws ZeroException if {@code data} has 0 elements
*/
public static <T extends FieldElement<T>> FieldVector<T> createFieldVector(final T[] data) {
if (data == null) {
throw new NullArgumentException();
}
if (data.length == 0) {
throw new ZeroException(LocalizedFormats.VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT);
}
return new ArrayFieldVector<T>(data[0].getField(), data, true);
}