Vector

Vector

High-Precision Vector class optimized for BigFloat arithmetic. Represents a mathematical column vector.

Constructor

new Vector(data)

Description:
  • Initializes a Vector from a size, an existing array, or another Vector.

Source:
Parameters:
Name Type Description
data number | Array.<(number|string|BigFloat)> | Vector

Classes

Vector

Members

length

Description:
  • Dimension of the vector.

Source:

Dimension of the vector.

Methods

add(other) → {Vector}

Description:
  • Adds another vector to this vector (v = this + other).

Source:
Parameters:
Name Type Description
other Vector
Returns:
Type
Vector

clone() → {Vector}

Description:
  • Deep clones the vector.

Source:
Returns:
Type
Vector

dot(other) → {BigFloat}

Description:
  • Computes the dot product of this vector and another vector.

Source:
Parameters:
Name Type Description
other Vector
Returns:
Type
BigFloat

get(i) → {BigFloat}

Description:
  • Gets the value at index i.

Source:
Parameters:
Name Type Description
i number
Returns:
Type
BigFloat

norm() → {BigFloat}

Description:
  • Computes the L2 norm (Euclidean norm) of the vector.

Source:
Returns:
Type
BigFloat

scale(scalar) → {Vector}

Description:
  • Multiplies the vector by a scalar (v = this * scalar).

Source:
Parameters:
Name Type Description
scalar number | string | BigFloat
Returns:
Type
Vector

set(i, val)

Description:
  • Sets the value at index i.

Source:
Parameters:
Name Type Description
i number
val number | string | BigFloat

sub(other) → {Vector}

Description:
  • Subtracts another vector from this vector (v = this - other).

Source:
Parameters:
Name Type Description
other Vector
Returns:
Type
Vector

toArray() → {Array.<BigFloat>}

Description:
  • Converts the vector to a standard Javascript Array of BigFloats.

Source:
Returns:
Type
Array.<BigFloat>

toString(radix, prec, maxItem) → {string}

Description:
  • Returns a string representation of the vector. Truncates the middle part with "..." if the length exceeds maxItem.

Source:
Parameters:
Name Type Default Description
radix number 10

The base for number representation (e.g., 10).

prec number 2

The number of decimal places for BigFloat.

maxItem number 10

Maximum number of elements to show before truncating.

Returns:
Type
string