mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-30 16:00:20 +02:00
Enable list-of-matrix use of vmul().
This commit is contained in:
@@ -59,16 +59,15 @@ function vang(v) =
|
||||
|
||||
// Function: vmul()
|
||||
// Description:
|
||||
// Element-wise vector multiplication. Multiplies each element of vector `v1` by
|
||||
// the corresponding element of vector `v2`. The vectors should have the same dimension.
|
||||
// Returns a vector of the products.
|
||||
// Element-wise multiplication. Multiplies each element of `v1` by the corresponding element of `v2`.
|
||||
// Both `v1` and `v2` must be the same length. Returns a vector of the products.
|
||||
// Arguments:
|
||||
// v1 = The first vector.
|
||||
// v2 = The second vector.
|
||||
// Example:
|
||||
// vmul([3,4,5], [8,7,6]); // Returns [24, 28, 30]
|
||||
function vmul(v1, v2) =
|
||||
assert( is_vector(v1) && is_vector(v2,len(v1)), "Incompatible vectors")
|
||||
assert( is_list(v1) && is_list(v2) && len(v1)==len(v2), "Incompatible input")
|
||||
[for (i = [0:1:len(v1)-1]) v1[i]*v2[i]];
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user