Edges() { latEdge = (ArrayDouble.D2) latAxis2D.getCoordBoundsAsArray(); lonEdge = (ArrayDouble.D2) lonAxis2D.getCoordBoundsAsArray(); // assume missing values have been converted to NaNs latMinMax = MAMath.getMinMax(latEdge); lonMinMax = MAMath.getMinMax(lonEdge); // normalize to [minLon,minLon+360] int nlons = (int) lonEdge.getSize(); for (int i = 0; i < nlons; i++) { double nonVal = lonEdge.getDouble(i); lonEdge.setDouble(i, LatLonPointImpl.lonNormalFrom(nonVal, lonMinMax.min)); } if (debug) System.out.printf("Bounds (%d %d): lat= (%f,%f) lon = (%f,%f) %n", nrows, ncols, latMinMax.min, latMinMax.max, lonMinMax.min, lonMinMax.max); }
/** * Matrix multiply: return m1 * m2. * @param m1 left matrix * @param m2 right matrix * @return MAMatrix result: new matrix * @exception IllegalArgumentException if m1.getNcols() != m2.getNrows(). */ static public MAMatrix multiply(MAMatrix m1, MAMatrix m2) { if (m1.getNcols() != m2.getNrows()) throw new IllegalArgumentException("MAMatrix.multiply "+m1.getNcols()+" != "+ m2.getNrows()); int kdims = m1.getNcols(); ArrayDouble.D2 result = new ArrayDouble.D2(m1.getNrows(), m2.getNcols()); Index imr = result.getIndex(); for (int i=0; i<m1.getNrows(); i++) { for (int j=0; j<m2.getNcols(); j++) { double sum = 0.0; for (int k=0; k<kdims; k++) sum += m1.getDouble(i, k) * m2.getDouble(k, j); result.setDouble( imr.set(i,j), sum); } } return new MAMatrix( result); }
/** * Matrix multiply: return m1 * m2. * @param m1 left matrix * @param m2 right matrix * @return MAMatrix result: new matrix * @exception IllegalArgumentException if m1.getNcols() != m2.getNrows(). */ static public MAMatrix multiply(MAMatrix m1, MAMatrix m2) { if (m1.getNcols() != m2.getNrows()) throw new IllegalArgumentException("MAMatrix.multiply "+m1.getNcols()+" != "+ m2.getNrows()); int kdims = m1.getNcols(); ArrayDouble.D2 result = new ArrayDouble.D2(m1.getNrows(), m2.getNcols()); Index imr = result.getIndex(); for (int i=0; i<m1.getNrows(); i++) { for (int j=0; j<m2.getNcols(); j++) { double sum = 0.0; for (int k=0; k<kdims; k++) sum += m1.getDouble(i, k) * m2.getDouble(k, j); result.setDouble( imr.set(i,j), sum); } } return new MAMatrix( result); }
for (i=0; i<latDim.getLength(); i++) for (j=0; j<lonDim.getLength(); j++) Ad.setDouble(ima.set(i,j), (double) (i*10.0+j)); Ad.set(1,1,-999.99); ncfile.write("m1", new int[2], Ad);
/** * Matrix multiply: return m1 * m2. * @param m1 left matrix * @param m2 right matrix * @return MAMatrix result: new matrix * @exception IllegalArgumentException if m1.getNcols() != m2.getNrows(). */ static public MAMatrix multiply(MAMatrix m1, MAMatrix m2) { if (m1.getNcols() != m2.getNrows()) throw new IllegalArgumentException("MAMatrix.multiply "+m1.getNcols()+" != "+ m2.getNrows()); int kdims = m1.getNcols(); ArrayDouble.D2 result = new ArrayDouble.D2(m1.getNrows(), m2.getNcols()); Index imr = result.getIndex(); for (int i=0; i<m1.getNrows(); i++) { for (int j=0; j<m2.getNcols(); j++) { double sum = 0.0; for (int k=0; k<kdims; k++) sum += m1.getDouble(i, k) * m2.getDouble(k, j); result.setDouble( imr.set(i,j), sum); } } return new MAMatrix( result); }