Expanded sqr() to take lists and removed vsqr()

This commit is contained in:
Adrian Mariano 2020-03-21 09:19:49 -04:00
parent 79358ddf6f
commit 72aae0e42c
2 changed files with 7 additions and 11 deletions

View file

@ -26,11 +26,14 @@ NAN = acos(2); // The value `nan`, useful for comparisons.
// Usage:
// sqr(x);
// Description:
// Returns the square of the given number.
// Returns the square of the given number or entries in list
// Examples:
// sqr(3); // Returns: 9
// sqr(-4); // Returns: 16
function sqr(x) = x*x;
// sqr(3); // Returns: 9
// sqr(-4); // Returns: 16
// sqr([3,4]); // Returns: [9,16]
// sqr([[1,2],[3,4]]); // Returns [[1,4],[9,16]]
// sqr([[1,2],3]); // Returns [[1,4],9]
function sqr(x) = is_list(x) ? [for(val=x) sqr(val)] : x*x;
// Function: log2()

View file

@ -95,13 +95,6 @@ function vdiv(v1, v2) = [for (i = [0:1:len(v1)-1]) v1[i]/v2[i]];
function vabs(v) = [for (x=v) abs(x)];
// Function: vsqr()
// Usage:
// x = vsqr(v);
// Description:
// Returns a vector where each value in the original given vector is squared.
function vsqr(v) = [for(i=v) i*i];
// Function: unit()
// Description: