/** {@inheritDoc} */ @Override public double getEntry(int index) throws OutOfRangeException { checkIndex(index); return entries.get(index); }
/** {@inheritDoc} */ @Override public void setSubVector(int index, RealVector v) throws OutOfRangeException { checkIndex(index); checkIndex(index + v.getDimension() - 1); for (int i = 0; i < v.getDimension(); i++) { setEntry(i + index, v.getEntry(i)); } }
/** {@inheritDoc} */ @Override public void setEntry(int index, double value) throws OutOfRangeException { checkIndex(index); if (!isDefaultValue(value)) { entries.put(index, value); } else if (entries.containsKey(index)) { entries.remove(index); } }
/** {@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; }
/** {@inheritDoc} */ @Override public double getEntry(int index) throws OutOfRangeException { checkIndex(index); return entries.get(index); }
/** {@inheritDoc} */ @Override public double getEntry(int index) throws OutOfRangeException { checkIndex(index); return entries.get(index); }
/** {@inheritDoc} */ @Override public void setSubVector(int index, RealVector v) throws OutOfRangeException { checkIndex(index); checkIndex(index + v.getDimension() - 1); for (int i = 0; i < v.getDimension(); i++) { setEntry(i + index, v.getEntry(i)); } }
/** {@inheritDoc} */ @Override public void setSubVector(int index, RealVector v) throws OutOfRangeException { checkIndex(index); checkIndex(index + v.getDimension() - 1); for (int i = 0; i < v.getDimension(); i++) { setEntry(i + index, v.getEntry(i)); } }
/** {@inheritDoc} */ @Override public void setEntry(int index, double value) throws OutOfRangeException { checkIndex(index); if (!isDefaultValue(value)) { entries.put(index, value); } else if (entries.containsKey(index)) { entries.remove(index); } }
/** {@inheritDoc} */ @Override public void setEntry(int index, double value) throws OutOfRangeException { checkIndex(index); if (!isDefaultValue(value)) { entries.put(index, value); } else if (entries.containsKey(index)) { entries.remove(index); } }
/** {@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; }
/** {@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; }