Here you can find the source of norm(double[] a)
Parameter | Description |
---|---|
a | Description of the Parameter |
public static double norm(double[] a)
//package com.java2s; /**/*from w w w .j av a2 s. c o m*/ * This program is free software; you can * redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation (version 2). This * program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ public class Main { /** * Description of the Method * *@param a Description of the Parameter *@return Description of the Return Value */ public static double norm(double[] a) { return (double) Math.sqrt(innerproduct(a, a)); } public static double norm(double[][] a) { double sum = 0.0; for (int row = 0; row < a.length; ++row) sum += norm(a[row]); return sum / a.length; } /** * Description of the Method * *@param a Description of the Parameter *@param b Description of the Parameter *@return Description of the Return Value */ public static double innerproduct(final double[] a, final double[] b) { double answer = 0; for (int i = 0; i < a.length; ++i) answer += a[i] * b[i]; return answer; } }