/// <summary> /// Return coordinate matrices from coordinate vectors. /// Make N-D coordinate arrays for vectorized evaluations of /// N-D scalar/vector fields over N-D grids, given /// one-dimensional coordinate arrays x1, x2,..., xn. /// .. versionchanged:: 1.9 /// 1-D and 0-D cases are allowed. /// </summary> /// <param name="x1"> 1-D arrays representing the coordinates of a grid</param> /// /// <param name="x2"> 1-D arrays representing the coordinates of a grid</param> /// <returns></returns> public static (NDArray, NDArray) meshgrid(NDArray x1, NDArray x2, Kwargs kwargs = null) { if (kwargs == null) { kwargs = new Kwargs(); } int ndim = 2; var s0 = (1, 1); var output = new NDArray[] { x1.reshape(-1, 1), x2.reshape(1, -1) }; if (kwargs.indexing == "xy" && ndim > 1) { // Switch first and second axis output[0].reshape(1, -1); output[1].reshape(-1, 1); } if (!kwargs.sparse) { // Return the full N-D matrix(not only the 1 - D vector) output = np.broadcast_arrays(output[0], output[1], true); } if (kwargs.copy) { } return(output[0], output[1]); }
public NDArray reshape(NDArray nd, params int[] shape) { nd.reshape(shape); return(nd); }
public static NDArray squeeze(NDArray nd, int axis = -1) { return(nd.reshape(nd.shape.Where(x => x > 1).ToArray())); }