Enable list-of-matrix use of vmul().

This commit is contained in:
Garth Minette
2020-09-28 17:35:05 -07:00
parent 23bcc1b806
commit cc29e07d8f
3 changed files with 7 additions and 7 deletions

View File

@@ -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]];