mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Enable list-of-matrix use of vmul().
This commit is contained in:
parent
23bcc1b806
commit
cc29e07d8f
3 changed files with 7 additions and 7 deletions
|
@ -41,8 +41,9 @@ test_vceil();
|
||||||
|
|
||||||
|
|
||||||
module test_vmul() {
|
module test_vmul() {
|
||||||
assert(vmul([3,4,5], [8,7,6]) == [24,28,30]);
|
assert_equal(vmul([3,4,5], [8,7,6]), [24,28,30]);
|
||||||
assert(vmul([1,2,3], [4,5,6]) == [4,10,18]);
|
assert_equal(vmul([1,2,3], [4,5,6]), [4,10,18]);
|
||||||
|
assert_equal(vmul([[1,2,3],[4,5,6],[7,8,9]], [[4,5,6],[3,2,1],[5,9,3]]), [32,28,134]);
|
||||||
}
|
}
|
||||||
test_vmul();
|
test_vmul();
|
||||||
|
|
||||||
|
|
|
@ -59,16 +59,15 @@ function vang(v) =
|
||||||
|
|
||||||
// Function: vmul()
|
// Function: vmul()
|
||||||
// Description:
|
// Description:
|
||||||
// Element-wise vector multiplication. Multiplies each element of vector `v1` by
|
// Element-wise multiplication. Multiplies each element of `v1` by the corresponding element of `v2`.
|
||||||
// the corresponding element of vector `v2`. The vectors should have the same dimension.
|
// Both `v1` and `v2` must be the same length. Returns a vector of the products.
|
||||||
// Returns a vector of the products.
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// v1 = The first vector.
|
// v1 = The first vector.
|
||||||
// v2 = The second vector.
|
// v2 = The second vector.
|
||||||
// Example:
|
// Example:
|
||||||
// vmul([3,4,5], [8,7,6]); // Returns [24, 28, 30]
|
// vmul([3,4,5], [8,7,6]); // Returns [24, 28, 30]
|
||||||
function vmul(v1, v2) =
|
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]];
|
[for (i = [0:1:len(v1)-1]) v1[i]*v2[i]];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,434];
|
BOSL_VERSION = [2,0,435];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue