ArrayFieldVector can now be constructed from any FieldVector.
Thanks to Arne Plöse. JIRA: MATH-570 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1455260 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cb5e94419f
commit
62f86d9580
|
@ -55,6 +55,9 @@ This is a minor release: It combines bug fixes and new features.
|
|||
Changes to existing features were made in a backwards-compatible
|
||||
way such as to allow drop-in replacement of the v3.1[.1] JAR file.
|
||||
">
|
||||
<action dev="luc" type="fix" issue="MATH-570" due-to="Arne Plöse" >
|
||||
ArrayFieldVector can now be constructed from any FieldVector.
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-861" due-to="Sébastien Brisard" >
|
||||
Improved checking of null vector elements.
|
||||
</action>
|
||||
|
|
|
@ -269,15 +269,12 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
* @param v2 Second vector (will be put at back of the new vector).
|
||||
* @throws NullArgumentException if {@code v1} or {@code v2} is
|
||||
* {@code null}.
|
||||
* @deprecated as of 3.2, replaced by {@link #ArrayFieldVector(FieldVector, FieldVector)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ArrayFieldVector(ArrayFieldVector<T> v1, ArrayFieldVector<T> v2)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(v1);
|
||||
MathUtils.checkNotNull(v2);
|
||||
field = v1.getField();
|
||||
data = MathArrays.buildArray(field, v1.data.length + v2.data.length);
|
||||
System.arraycopy(v1.data, 0, data, 0, v1.data.length);
|
||||
System.arraycopy(v2.data, 0, data, v1.data.length, v2.data.length);
|
||||
this((FieldVector<T>) v1, (FieldVector<T>) v2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,15 +284,35 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
* @param v2 Second vector (will be put at back of the new vector).
|
||||
* @throws NullArgumentException if {@code v1} or {@code v2} is
|
||||
* {@code null}.
|
||||
* @since 3.2
|
||||
*/
|
||||
public ArrayFieldVector(ArrayFieldVector<T> v1, T[] v2)
|
||||
public ArrayFieldVector(FieldVector<T> v1, FieldVector<T> v2)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(v1);
|
||||
MathUtils.checkNotNull(v2);
|
||||
field = v1.getField();
|
||||
data = MathArrays.buildArray(field, v1.data.length + v2.length);
|
||||
System.arraycopy(v1.data, 0, data, 0, v1.data.length);
|
||||
System.arraycopy(v2, 0, data, v1.data.length, v2.length);
|
||||
final T[] v1Data =
|
||||
(v1 instanceof ArrayFieldVector) ? ((ArrayFieldVector<T>) v1).data : v1.toArray();
|
||||
final T[] v2Data =
|
||||
(v2 instanceof ArrayFieldVector) ? ((ArrayFieldVector<T>) v2).data : v2.toArray();
|
||||
data = MathArrays.buildArray(field, v1Data.length + v2Data.length);
|
||||
System.arraycopy(v1Data, 0, data, 0, v1Data.length);
|
||||
System.arraycopy(v2Data, 0, data, v1Data.length, v2Data.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a vector by appending one vector to another vector.
|
||||
*
|
||||
* @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}.
|
||||
* @deprecated as of 3.2, replaced by {@link #ArrayFieldVector(FieldVector, FieldElement[])
|
||||
*/
|
||||
@Deprecated
|
||||
public ArrayFieldVector(ArrayFieldVector<T> v1, T[] v2)
|
||||
throws NullArgumentException {
|
||||
this((FieldVector<T>) v1, v2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,14 +323,51 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
* @throws NullArgumentException if {@code v1} or {@code v2} is
|
||||
* {@code null}.
|
||||
*/
|
||||
public ArrayFieldVector(FieldVector<T> v1, T[] v2)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(v1);
|
||||
MathUtils.checkNotNull(v2);
|
||||
field = v1.getField();
|
||||
final T[] v1Data =
|
||||
(v1 instanceof ArrayFieldVector) ? ((ArrayFieldVector<T>) v1).data : v1.toArray();
|
||||
data = MathArrays.buildArray(field, v1Data.length + v2.length);
|
||||
System.arraycopy(v1Data, 0, data, 0, v1Data.length);
|
||||
System.arraycopy(v2, 0, data, v1Data.length, v2.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a vector by appending one vector to another vector.
|
||||
*
|
||||
* @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}.
|
||||
* @deprecated as of 3.2, replaced by {@link #ArrayFieldVector(FieldElement[], FieldVector)
|
||||
*/
|
||||
@Deprecated
|
||||
public ArrayFieldVector(T[] v1, ArrayFieldVector<T> v2)
|
||||
throws NullArgumentException {
|
||||
this(v1, (FieldVector<T>) v2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a vector by appending one vector to another vector.
|
||||
*
|
||||
* @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}.
|
||||
*/
|
||||
public ArrayFieldVector(T[] v1, FieldVector<T> v2)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(v1);
|
||||
MathUtils.checkNotNull(v2);
|
||||
field = v2.getField();
|
||||
data = MathArrays.buildArray(field, v1.length + v2.data.length);
|
||||
final T[] v2Data =
|
||||
(v2 instanceof ArrayFieldVector) ? ((ArrayFieldVector<T>) v2).data : v2.toArray();
|
||||
data = MathArrays.buildArray(field, v1.length + v2Data.length);
|
||||
System.arraycopy(v1, 0, data, 0, v1.length);
|
||||
System.arraycopy(v2.data, 0, data, v1.length, v2.data.length);
|
||||
System.arraycopy(v2Data, 0, data, v1.length, v2Data.length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue