src/linearalgebra.js
function norm(arr, p) {
    var nnorm = 0,
    i = 0;
    // check the p-value of the norm, and set for most common case
    if (isNaN(p)) p = 2;
    // check if multi-dimensional array, and make vector correction
    if (isUsable(arr[0])) arr = arr[0];
    // vector norm
    for (; i < arr.length; i++) {
      nnorm += Math.pow(Math.abs(arr[i]), p);
    }
    return Math.pow(nnorm, 1 / p);
  }
function norm(arr, p) {
    var nnorm = 0,
    i = 0;
    // check the p-value of the norm, and set for most common case
    if (isNaN(p)) p = 2;
    // check if multi-dimensional array, and make vector correction
    if (isUsable(arr[0])) arr = arr[0];
    // vector norm
    for (; i < arr.length; i++) {
      nnorm += Math.pow(Math.abs(arr[i]), p);
    }
    return Math.pow(nnorm, 1 / p);
  }
function norm ( arr , p ) { var nnorm = 0 , i = 0 ; // check the p-value of the norm, and set for most common case if ( isNaN ( p ) ) p = 2 ; // check if multi-dimensional array, and make vector correction if ( isUsable ( arr [ 0 ] ) ) arr = arr [ 0 ] ; // vector norm for ( ; i < arr . length ; i ++ ) { nnorm += Math . pow ( Math . abs ( arr [ i ] ) , p ) ; } return Math . pow ( nnorm , 1 / p ) ; }
computes the p-norm of the vector In the case that a matrix is passed, uses the first row as the vector
computes the p - norm of the vector In the case that a matrix is passed uses the first row as the vector