Mathematical vector operations.
[]
[[VectorProto]] defines most of the functions.
Vectors implements also:
Sequable
Sequencial
IFn
Counted
Reversible
Indexed
ILookup
equals
and toString
from Object
IPersistentVector
Associative
clojure.core.matrix.protocols
IReduce
and IReduceInit
That means that vectors can be destructured, treated as sequence or called as a function. See vec2
for examples.
Mathematical vector operations. ### Types * Fixed size (custom types): * Number - 1d vector * Vec2 - 2d vector, creator [[vec2]] * Vec3 - 3d vector, creator [[vec3]] * Vec4 - 4d vector, creator [[vec4]] * ArrayVec - fixed size double array wrapper, n-dimensional, creator [[array-vec]] * Fixed size * doubles - double array itself * Variable size: * Clojure's IPersistentVector, creator `[]` * Clojure's ISeq [[VectorProto]] defines most of the functions. Vectors implements also: * `Sequable` * `Sequencial` * `IFn` * `Counted` * `Reversible` * `Indexed` * `ILookup` * `equals` and `toString` from `Object` * `IPersistentVector` * `Associative` * `clojure.core.matrix.protocols` * `IReduce` and `IReduceInit` That means that vectors can be destructured, treated as sequence or called as a function. See [[vec2]] for examples.
(abs v)
Absolute value of vector elements
Absolute value of vector elements
(acos vector)
Apply acos to vector elements.
Apply acos to vector elements.
(acosh vector)
Apply acosh to vector elements.
Apply acosh to vector elements.
(acot vector)
Apply acot to vector elements.
Apply acot to vector elements.
(acoth vector)
Apply acoth to vector elements.
Apply acoth to vector elements.
(acsc vector)
Apply acsc to vector elements.
Apply acsc to vector elements.
(acsch vector)
Apply acsch to vector elements.
Apply acsch to vector elements.
(aligned? v1 v2)
(aligned? v1 v2 tol)
Are vectors aligned (have the same direction)?
Are vectors aligned (have the same direction)?
(angle-between v1 v2)
Angle between two vectors
See also relative-angle-between
.
Angle between two vectors See also [[relative-angle-between]].
(approx v)
(approx v d)
Round to 2 (or d
) decimal places
Round to 2 (or `d`) decimal places
(array-vec xs)
Make ArrayVec type based on provided sequence xs
.
Make ArrayVec type based on provided sequence `xs`.
(as-vec v)
(as-vec v xs)
Create vector from sequence as given type. If there is no sequence fill with 0.0
.
Create vector from sequence as given type. If there is no sequence fill with `0.0`.
(asec vector)
Apply asec to vector elements.
Apply asec to vector elements.
(asech vector)
Apply asech to vector elements.
Apply asech to vector elements.
(asin vector)
Apply asin to vector elements.
Apply asin to vector elements.
(asinh vector)
Apply asinh to vector elements.
Apply asinh to vector elements.
(atan vector)
Apply atan to vector elements.
Apply atan to vector elements.
(atanh vector)
Apply atanh to vector elements.
Apply atanh to vector elements.
(average v)
(average v weights)
Mean or weighted average of the vector
Mean or weighted average of the vector
(average-vectors vs)
(average-vectors init vs)
Average / centroid of vectors. Input: initial vector (optional), list of vectors
Average / centroid of vectors. Input: initial vector (optional), list of vectors
(axis-rotate v angle axis)
(axis-rotate v angle axis pivot)
Rotate vector. Only for Vec3
types
Rotate vector. Only for `Vec3` types
(base-from v)
List of perpendicular vectors (basis). Works only for Vec2
and Vec3
types.
List of perpendicular vectors (basis). Works only for `Vec2` and `Vec3` types.
(cbrt vector)
Apply cbrt to vector elements.
Apply cbrt to vector elements.
(ceil vector)
Apply ceil to vector elements.
Apply ceil to vector elements.
(cosh vector)
Apply cosh to vector elements.
Apply cosh to vector elements.
(coth vector)
Apply coth to vector elements.
Apply coth to vector elements.
(csch vector)
Apply csch to vector elements.
Apply csch to vector elements.
(degrees vector)
Apply degrees to vector elements.
Apply degrees to vector elements.
(delta-eq v1 v2)
(delta-eq v1 v2 abs-tol)
(delta-eq v1 v2 abs-tol rel-tol)
Equality with given absolute (and/or relative) toleance.
Equality with given absolute (and/or relative) toleance.
(dist v1 v2)
Euclidean distance between vectors
Euclidean distance between vectors
(dist-abs v1 v2)
Manhattan distance between vectors
Manhattan distance between vectors
(dist-cheb v1 v2)
Chebyshev distance between 2d vectors
Chebyshev distance between 2d vectors
(dist-discrete v1 v2)
Discrete distance between 2d vectors
Discrete distance between 2d vectors
(dist-sq v1 v2)
Squared Euclidean distance between vectors
Squared Euclidean distance between vectors
(div v1)
(div v1 v)
Vector division or reciprocal.
Vector division or reciprocal.
(edelta-eq v1 v2)
(edelta-eq v1 v2 abs-tol)
(edelta-eq v1 v2 abs-tol rel-tol)
Element-wise equality with given absolute (and/or relative) toleance.
Element-wise equality with given absolute (and/or relative) toleance.
(ediv v1 v2)
Element-wise division of two vectors.
Element-wise division of two vectors.
(einterpolate v1 v2 v)
(einterpolate v1 v2 v f)
Interpolate vector selement-wise, optionally set interpolation fn (default: lerp)
Interpolate vector selement-wise, optionally set interpolation fn (default: lerp)
(emn v1 v2)
Element-wise min from two vectors.
Element-wise min from two vectors.
(emult v1 v2)
Element-wise vector multiplication (Hadamard product).
Element-wise vector multiplication (Hadamard product).
(emx v1 v2)
Element-wise max from two vectors.
Element-wise max from two vectors.
(expm1 vector)
Apply expm1 to vector elements.
Apply expm1 to vector elements.
(faceforward n v)
Flip normal n
to match the same direction as v
.
Flip normal `n` to match the same direction as `v`.
(floor vector)
Apply floor to vector elements.
Apply floor to vector elements.
(fmap v f)
Apply function to all vector values (like map but returns the same type).
Apply function to all vector values (like map but returns the same type).
(frac vector)
Apply frac to vector elements.
Apply frac to vector elements.
(from-polar v)
From polar coordinates (2d, 3d only)
From polar coordinates (2d, 3d only)
(generate-vec2 f)
(generate-vec2 f1 f2)
Generate Vec2 with fn(s)
Generate Vec2 with fn(s)
(generate-vec3 f)
(generate-vec3 f1 f2 f3)
Generate Vec3 with fn(s)
Generate Vec3 with fn(s)
(generate-vec4 f)
(generate-vec4 f1 f2 f3 f4)
Generate Vec4 with fn(s)
Generate Vec4 with fn(s)
(heading v)
Angle between vector and unit vector [1,0,...]
Angle between vector and unit vector `[1,0,...]`
(interpolate v1 v2 t)
(interpolate v1 v2 t f)
Interpolate vectors, optionally set interpolation fn (default: lerp)
Interpolate vectors, optionally set interpolation fn (default: lerp)
(is-near-zero? v)
(is-near-zero? v abs-tol)
(is-near-zero? v abs-tol rel-tol)
Equality to zero 0
with given absolute (and/or relative) toleance.
Equality to zero `0` with given absolute (and/or relative) toleance.
(lerp v1 v2 t)
Linear interpolation of vectors
Linear interpolation of vectors
(limit v len)
Limit length of the vector by given value
Limit length of the vector by given value
(log10 vector)
Apply log10 to vector elements.
Apply log10 to vector elements.
(log1mexp vector)
Apply log1mexp to vector elements.
Apply log1mexp to vector elements.
(log1p vector)
Apply log1p to vector elements.
Apply log1p to vector elements.
(log1pexp vector)
Apply log1pexp to vector elements.
Apply log1pexp to vector elements.
(log1pmx vector)
Apply log1pmx to vector elements.
Apply log1pmx to vector elements.
(log1psq vector)
Apply log1psq to vector elements.
Apply log1psq to vector elements.
(log2 vector)
Apply log2 to vector elements.
Apply log2 to vector elements.
(logexpm1 vector)
Apply logexpm1 to vector elements.
Apply logexpm1 to vector elements.
(logit vector)
Apply logit to vector elements.
Apply logit to vector elements.
(logmxp1 vector)
Apply logmxp1 to vector elements.
Apply logmxp1 to vector elements.
(make-vector dims)
(make-vector dims xs)
Returns fixed size vector for given number of dimensions.
Proper type is used.
Returns fixed size vector for given number of dimensions. Proper type is used.
(near-zero? v)
(near-zero? v abs-tol)
(near-zero? v abs-tol rel-tol)
Equality to zero 0
with given absolute (and/or relative) toleance.
Equality to zero `0` with given absolute (and/or relative) toleance.
(nonzero-count v)
Count non zero velues in vector
Count non zero velues in vector
(normalize v)
Normalize vector (set length = 1.0)
Normalize vector (set length = 1.0)
(orthogonal-polynomials xs)
Creates orthogonal list of vectors based on xs
, starting from degree 1
Creates orthogonal list of vectors based on `xs`, starting from degree 1
(orthonormal-polynomials xs)
Creates orthonormal list of vector based on xs
, starting from degree 1
Creates orthonormal list of vector based on `xs`, starting from degree 1
(permute v idxs)
Permute vector elements with given indices.
Permute vector elements with given indices.
(perpendicular v)
(perpendicular v1 v2)
Perpendicular vector. Only for Vec2
and Vec3
types.
Perpendicular vector. Only for `Vec2` and `Vec3` types.
(radians vector)
Apply radians to vector elements.
Apply radians to vector elements.
(relative-angle-between v1 v2)
Angle between two vectors relative to each other.
See also angle-between
.
Angle between two vectors relative to each other. See also [[angle-between]].
(rint vector)
Apply rint to vector elements.
Apply rint to vector elements.
(rotate v angle)
(rotate v angle-x angle-y angle-z)
Rotate vector. Only for Vec2
and Vec3
types.
Rotate vector. Only for `Vec2` and `Vec3` types.
(round vector)
Apply round to vector elements.
Apply round to vector elements.
(safe-sqrt vector)
Apply safe-sqrt to vector elements.
Apply safe-sqrt to vector elements.
(sech vector)
Apply sech to vector elements.
Apply sech to vector elements.
(sfrac vector)
Apply sfrac to vector elements.
Apply sfrac to vector elements.
(shift v)
(shift v x)
Add value to every vector element.
Add value to every vector element.
(sigmoid vector)
Apply sigmoid to vector elements.
Apply sigmoid to vector elements.
(signum vector)
Apply signum to vector elements.
Apply signum to vector elements.
(sinc vector)
Apply sinc to vector elements.
Apply sinc to vector elements.
(sinh vector)
Apply sinh to vector elements.
Apply sinh to vector elements.
(sqrt vector)
Apply sqrt to vector elements.
Apply sqrt to vector elements.
(tanh vector)
Apply tanh to vector elements.
Apply tanh to vector elements.
(to-polar v)
To polar coordinates (2d, 3d only), first element is length, the rest angle.
To polar coordinates (2d, 3d only), first element is length, the rest angle.
Same as vec->Vec
. Deprecated.
Same as [[vec->Vec]]. Deprecated.
(transform v o vx vy)
(transform v o vx vy vz)
Transform vector; map point to coordinate system defined by origin, vx and vy (as bases), Only for Vec2
and Vec3
types.
Transform vector; map point to coordinate system defined by origin, vx and vy (as bases), Only for `Vec2` and `Vec3` types.
(trunc vector)
Apply trunc to vector elements.
Apply trunc to vector elements.
(vec->RealVector v)
Convert to Apache Commons Math RealVector
Convert to Apache Commons Math RealVector
(vec->seq v)
Convert to sequence (same as seq)
Convert to sequence (same as seq)
(vec->Vec v)
Convert to Clojure primitive vector Vec
.
Convert to Clojure primitive vector `Vec`.
(vec4)
(vec4 v w)
(vec4 v z w)
(vec4 x y z w)
Make Vec4 vector
Make Vec4 vector
(xlogx vector)
Apply xlogx to vector elements.
Apply xlogx to vector elements.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close