VECTOR_INDEXING
Download Flojoy Studio to try this app
The VECTOR_INDEXING node returns the value of the vector at the requested index. Inputs
------
v : vector
The input vector to index. Params: index : int The index of the vector to return. Returns: out : Scalar The scalar index of the input vector.
Python Code
from flojoy import flojoy, Vector, Scalar
@flojoy
def VECTOR_INDEXING(
default: Vector,
index: int = 0,
) -> Scalar:
"""The VECTOR_INDEXING node returns the value of the vector at the requested index.
Inputs
------
v : vector
The input vector to index.
Parameters
----------
index : int
The index of the vector to return.
Returns
-------
Scalar
The scalar index of the input vector.
"""
assert (
len(default.v) > index
), "The index parameter must be less than the length of the Vector."
assert index >= 0, "The index parameter must be greater than zero."
c = default.v[index]
return Scalar(c=c)
Example App
Having problems with this example app? Join our Discord community and we will help you out!
In this example, we generate a vector by using a LINSPACE
node. Then, the value at index 100 is extracted at using VECTOR_INDEXING
. The value is visualized with BIG_NUMBER
.