public static double [ ] [ ] orthonormalize ( final double [ ] [ ] m1 ) { final int columndimension = getColumnDimensionality ( m1 ) ; final double [ ] [ ] v = copy ( m1 ) ; // FIXME: optimize - excess copying! for ( int i = 1 ; i < columndimension ; i ++ ) { final double [ ] u_i = getCol ( m1 , i ) ; final double [ ] sum = new double [ m1 . length ] ; for ( int j = 0 ; j < i ; j ++ ) { final double [ ] v_j = getCol ( v , j ) ; final double scalar = scalarProduct ( u_i , v_j ) / scalarProduct ( v_j , v_j ) ; plusEquals ( sum , times ( v_j , scalar ) ) ; } final double [ ] v_i = minus ( u_i , sum ) ; setCol ( v , i , v_i ) ; } normalizeColumns ( v ) ; return v ; }
Returns an orthonormalization of this matrix .