Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Math_29_OpenMapRealVector_t.java    From coming with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public OpenMapRealVector getSubVector(int index, int n) {
    checkIndex(index);
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index + n - 1);
    OpenMapRealVector res = new OpenMapRealVector(n);
    int end = index + n;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 2
Source File: OpenMapRealVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public OpenMapRealVector getSubVector(int index, int n)
    throws NotPositiveException, OutOfRangeException {
    checkIndex(index);
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index + n - 1);
    OpenMapRealVector res = new OpenMapRealVector(n);
    int end = index + n;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 3
Source File: ArrayRealVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public RealVector getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    ArrayRealVector out = new ArrayRealVector(n);
    try {
        System.arraycopy(data, index, out.data, 0, n);
    } catch (IndexOutOfBoundsException e) {
        checkIndex(index);
        checkIndex(index + n - 1);
    }
    return out;
}
 
Example 4
Source File: OpenMapRealVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public OpenMapRealVector getSubVector(int index, int n)
    throws NotPositiveException, OutOfRangeException {
    checkIndex(index);
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index + n - 1);
    OpenMapRealVector res = new OpenMapRealVector(n);
    int end = index + n;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 5
Source File: SparseFieldVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
public FieldVector<T> getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index);
    checkIndex(index + n - 1);
    SparseFieldVector<T> res = new SparseFieldVector<T>(field,n);
    int end = index + n;
    OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 6
Source File: OpenMapRealVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public OpenMapRealVector getSubVector(int index, int n)
    throws NotPositiveException, OutOfRangeException {
    checkIndex(index);
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index + n - 1);
    OpenMapRealVector res = new OpenMapRealVector(n);
    int end = index + n;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 7
Source File: SparseFieldVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
public FieldVector<T> getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index);
    checkIndex(index + n - 1);
    SparseFieldVector<T> res = new SparseFieldVector<T>(field,n);
    int end = index + n;
    OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 8
Source File: OpenMapRealVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public OpenMapRealVector getSubVector(int index, int n)
    throws NotPositiveException, OutOfRangeException {
    checkIndex(index);
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index + n - 1);
    OpenMapRealVector res = new OpenMapRealVector(n);
    int end = index + n;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 9
Source File: ArrayRealVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public RealVector getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    ArrayRealVector out = new ArrayRealVector(n);
    try {
        System.arraycopy(data, index, out.data, 0, n);
    } catch (IndexOutOfBoundsException e) {
        checkIndex(index);
        checkIndex(index + n - 1);
    }
    return out;
}
 
Example 10
Source File: SparseFieldVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
public FieldVector<T> getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index);
    checkIndex(index + n - 1);
    SparseFieldVector<T> res = new SparseFieldVector<T>(field,n);
    int end = index + n;
    OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 11
Source File: OpenMapRealVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public OpenMapRealVector getSubVector(int index, int n)
    throws NotPositiveException, OutOfRangeException {
    checkIndex(index);
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index + n - 1);
    OpenMapRealVector res = new OpenMapRealVector(n);
    int end = index + n;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 12
Source File: ArrayRealVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public RealVector getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    ArrayRealVector out = new ArrayRealVector(n);
    try {
        System.arraycopy(data, index, out.data, 0, n);
    } catch (IndexOutOfBoundsException e) {
        checkIndex(index);
        checkIndex(index + n - 1);
    }
    return out;
}
 
Example 13
Source File: SparseFieldVector.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
public FieldVector<T> getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index);
    checkIndex(index + n - 1);
    SparseFieldVector<T> res = new SparseFieldVector<T>(field,n);
    int end = index + n;
    OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 14
Source File: OpenMapRealVector_s.java    From coming with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public OpenMapRealVector getSubVector(int index, int n) {
    checkIndex(index);
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index + n - 1);
    OpenMapRealVector res = new OpenMapRealVector(n);
    int end = index + n;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 15
Source File: OpenMapRealVector_t.java    From coming with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public OpenMapRealVector getSubVector(int index, int n) {
    checkIndex(index);
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index + n - 1);
    OpenMapRealVector res = new OpenMapRealVector(n);
    int end = index + n;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 16
Source File: Math_29_OpenMapRealVector_s.java    From coming with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public OpenMapRealVector getSubVector(int index, int n) {
    checkIndex(index);
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    checkIndex(index + n - 1);
    OpenMapRealVector res = new OpenMapRealVector(n);
    int end = index + n;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (key >= index && key < end) {
            res.setEntry(key - index, iter.value());
        }
    }
    return res;
}
 
Example 17
Source File: ArrayFieldVector.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public FieldVector<T> getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    ArrayFieldVector<T> out = new ArrayFieldVector<T>(field, n);
    try {
        System.arraycopy(data, index, out.data, 0, n);
    } catch (IndexOutOfBoundsException e) {
        checkIndex(index);
        checkIndex(index + n - 1);
    }
    return out;
}
 
Example 18
Source File: ArrayFieldVector.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public FieldVector<T> getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    ArrayFieldVector<T> out = new ArrayFieldVector<T>(field, n);
    try {
        System.arraycopy(data, index, out.data, 0, n);
    } catch (IndexOutOfBoundsException e) {
        checkIndex(index);
        checkIndex(index + n - 1);
    }
    return out;
}
 
Example 19
Source File: ArrayFieldVector.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public FieldVector<T> getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    ArrayFieldVector<T> out = new ArrayFieldVector<T>(field, n);
    try {
        System.arraycopy(data, index, out.data, 0, n);
    } catch (IndexOutOfBoundsException e) {
        checkIndex(index);
        checkIndex(index + n - 1);
    }
    return out;
}
 
Example 20
Source File: ArrayFieldVector.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public FieldVector<T> getSubVector(int index, int n)
    throws OutOfRangeException, NotPositiveException {
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
    }
    ArrayFieldVector<T> out = new ArrayFieldVector<T>(field, n);
    try {
        System.arraycopy(data, index, out.data, 0, n);
    } catch (IndexOutOfBoundsException e) {
        checkIndex(index);
        checkIndex(index + n - 1);
    }
    return out;
}