Gets a subvector of a given vector
(Head inclusive and tail inclusive)

@param z the vector
@return the subvector
322956
public float[] subVector(float[] z, int head, int tail) {
    int size = tail - head + 1;
    float[] result = new float[size];

    System.arraycopy(z, head, result, head - head, tail + 1 - head);

    return result;
  }
223421
public Vector3i sub(Vector3ic v) {
        return sub(v.x(), v.y(), v.z(), thisOrNew());
    }
1165484
static Vector2d getNearestVector(final Vector2d reference, final List<Vector2d> vectors) {

        if (vectors.isEmpty()) throw new IllegalArgumentException("No vectors provided");

        // to find the closest vector we find use the dot product,
        // for the general case (non-unit vectors) one can use the
        // cosine similarity
        Vector2d closest = vectors.get(0);
        double maxProd = reference.dot(closest);

        for (int i = 1; i < vectors.size(); i++) {
            double newProd = reference.dot(vectors.get(i));
            if (newProd > maxProd) {
                maxProd = newProd;
                closest = vectors.get(i);
            }
        }

        return closest;
    }
1078710
public Vector2i sub(Vector2ic v, Vector2i dest) {
        dest.x = x - v.x();
        dest.y = y - v.y();
        return dest;
    }
1215049
public VectorIterator nonZeroIteratorOfRow(int i) {
        final int ii = i;
        return new VectorIterator(columns) {
            private int j = -1;

            @Override
            public int index() {
                return j;
            }

            @Override
            public double get() {
                return SparseMatrix.this.get(ii, j);
            }

            @Override
            public void set(double value) {
                SparseMatrix.this.set(ii, j, value);
            }

            @Override
            public boolean hasNext() {
                while (j + 1 < columns && SparseMatrix.this.isZeroAt(ii, j + 1)) {
                    j++;
                }

                return j + 1 < columns;
            }

            @Override
            public Double next() {
                if(!hasNext()) {
                    throw new NoSuchElementException();
                }
                j++;
                return get();
            }
        };
    }
111068
public Vector3f sub(Vector3fc v, Vector3f dest) {
        dest.x = x - v.x();
        dest.y = y - v.y();
        dest.z = z - v.z();
        return dest;
    }
33037
public Vector3f reflect(float x, float y, float z) {
        return reflect(x, y, z, thisOrNew());
    }
635414
public Vector getSpinVector(double theta, double phi) {
        Vector spinvector = new Vector(3);
        spinvector.vector[0] = Math.sin(theta) * Math.cos(phi);
        spinvector.vector[1] = Math.sin(theta) * Math.sin(phi);
        spinvector.vector[2] = Math.cos(phi);
        return spinvector;
    }
1203410
public static ImmutableVector4 createVector(final double x, final double y, final double z, final double h) {
		return new ImmutableVector4(new ImmutableData(4, 1) {
			@Override
			public double getQuick(int row, int col) {
				switch (row) {
					case 0:
						return x;
					case 1:
						return y;
					case 2:
						return z;
					default:
						return h;
				}
			}
		});
	}
1288232
public Vector4f set(Vector2ic v, float z, float w) {
    	return set(v.x(), v.y(), z, w);
    }
1318846
public INDArray getVector(@NonNull Integer key, int rowIdx) {
        /**
         * we create VoidMessage, send it, and block until it gets responded
         */

        VectorRequestMessage message = new VectorRequestMessage(key, rowIdx);

        MeaningfulMessage response = transport.sendMessageAndGetResponse(message);

        return response.getPayload();
    }
963748
public SparseDoubleVector getColumnVector(int column) {
        checkIndices(0, column);
        rowReadLock.lock();
        SparseDoubleVector values = new SparseHashDoubleVector(rows.get());
        for (int row = 0; row < rows.get(); ++row) {
            AtomicSparseVector rowEntry = getRow(row, -1, false);            
            double value = 0;
            if (rowEntry != null && (value = rowEntry.get(column)) != 0)
                values.set(row, value);
        }
        rowReadLock.unlock();
        return values;
    }
456079
private <T extends FacetRank, K extends FacetRank> Optional<K> getVectorAxis(@NotNull Collection<K> secondVector, T entry) {
        return secondVector.stream()
                           .filter(facet -> {
                               return Facet.same(facet.getKey(), entry.getKey());
                           })
                           .findFirst();
    }
1075985
public static <T> Vector<T> getVector(int capacity, T... values) {
        return new Vector<T>() {{addAll(Arrays.asList(values));}};
    }
713186
public SparseDoubleVector getColumnVector(int column) {
        SparseDoubleVector values = new SparseHashDoubleVector(rows);
        for (int row = 0; row < rows; ++row) {
            double d = get(row, column);
            if (d != 0)
                values.set(row, d);
        }
        return values;
    }
187669
public Vector3 z(Vector3 q) {
		float z = z_value(q);
		return new Vector3(q.x, q.y, z);
	}
956622
public <F extends NumberVector> F getMeanVector(Relation<? extends F> relation) {
    return RelationUtil.getNumberVectorFactory(relation).newNumberVector(mean);
  }