예제 #1
0
 /**
  * Add the vector specified. This is a vector addition that does an element-by-element addition.
  *
  * @param other the vector to add.
  */
 public void add(FloatDenseVector other) {
   if (isSingleton) {
     throw new RuntimeException("Cannot add to singleton vector");
   }
   if (other.isSingleton) {
     ensureCapacity(other.singletonIndex + 1);
     entries.set(
         other.singletonIndex, entries.getFloat(other.singletonIndex) + other.singletonValue);
   } else {
     ensureCapacity(other.entries.size());
     for (int i = 0; i < other.entries.size(); ++i) {
       entries.set(i, entries.getFloat(i) + other.entries.getFloat(i));
     }
   }
 }
예제 #2
0
 /**
  * Set the given value to the entry with the index specified.
  *
  * @param i the entry
  * @param value the value to set to the entry
  */
 public void set(int i, float value) {
   entries.set(i, value);
 }