/// <summary> /// Returns the one-norm of vector <i>x</i>, which is <i>Sum(abs(x[i]))</i>. /// </summary> /// <param name="x"> /// The vector x. /// </param> /// <returns> /// The one-norm of x. /// </returns> public static double Norm1(DoubleMatrix1D x) { if (x.Size == 0) { return(0); } return(x.Aggregate(BinaryFunctions.Plus, Math.Abs)); }
/// <summary> /// Returns the infinity norm of vector <i>x</i>, which is <i>Max(abs(x[i]))</i>. /// </summary> /// <param name="x">The vector x.</param> /// <returns>The infinity norm of matrix <i>A</i></returns> public static double NormInfinity(DoubleMatrix1D x) { // fix for bug reported by [email protected] if (x.Size == 0) { return(0); } return(x.Aggregate(Math.Max, Math.Abs)); // if (x.Size==0) return 0; // return x.aggregate(cern.Cern.Jet.math.Functions.plus,cern.Cern.Jet.math.Functions.abs); // double max = 0; // for (int i = x.Size; --i >= 0; ) { // max = System.Math.Max(max, x.getQuick(i)); // } // return max; }
public double Dasum(DoubleMatrix1D x) { return(x.Aggregate(F2.Plus, F1.Abs)); }