From 23bcc1b806e27b454422039a74423cd7d53cde9e Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Mon, 28 Sep 2020 16:56:18 -0700 Subject: [PATCH] Removed sum_of_squares() as it's redundant with sqr(vector) --- math.scad | 14 +------------- tests/test_math.scad | 8 -------- version.scad | 2 +- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/math.scad b/math.scad index 574f098..9a0a26e 100644 --- a/math.scad +++ b/math.scad @@ -552,18 +552,6 @@ function _cumsum(v,_i=0,_acc=[]) = ); -// Function: sum_of_squares() -// Description: -// Returns the sum of the square of each element of a vector. -// Arguments: -// v = The vector to get the sum of. -// Example: -// sum_of_squares([1,2,3]); // Returns: 14. -// sum_of_squares([1,2,4]); // Returns: 21 -// sum_of_squares([-3,-2,-1]); // Returns: 14 -function sum_of_squares(v) = sum(vmul(v,v)); - - // Function: sum_of_sines() // Usage: // sum_of_sines(a,sines) @@ -760,7 +748,7 @@ function _qr_factor(A,Q,P, pivot, column, m, n) = column >= min(m-1,n) ? [Q,A,P] : let( swap = !pivot ? 1 - : _swap_matrix(n,column,column+max_index([for(i=[column:n-1]) sum_of_squares([for(j=[column:m-1]) A[j][i]])])), + : _swap_matrix(n,column,column+max_index([for(i=[column:n-1]) sqr([for(j=[column:m-1]) A[j][i]])])), A = pivot ? A*swap : A, x = [for(i=[column:1:m-1]) A[i][column]], alpha = (x[0]<=0 ? 1 : -1) * norm(x), diff --git a/tests/test_math.scad b/tests/test_math.scad index 2ba6a1a..2f1faaf 100644 --- a/tests/test_math.scad +++ b/tests/test_math.scad @@ -472,14 +472,6 @@ module test_cumsum() { test_cumsum(); -module test_sum_of_squares() { - assert_equal(sum_of_squares([1,2,3]), 14); - assert_equal(sum_of_squares([1,2,4]), 21); - assert_equal(sum_of_squares([-3,-2,-1]), 14); -} -test_sum_of_squares(); - - module test_sum_of_sines() { assert_equal(sum_of_sines(0, [[3,4,0],[2,2,0]]), 0); assert_equal(sum_of_sines(45, [[3,4,0],[2,2,0]]), 2); diff --git a/version.scad b/version.scad index 6da91fa..9d80cf4 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,433]; +BOSL_VERSION = [2,0,434]; // Section: BOSL Library Version Functions