matrix

Write matrix with Fortran

我们两清 提交于 2019-12-25 16:38:12
问题 I need to output a matrix with FORTRAN. I have a working code that calculates the values, but instead of a matrix, I get single a column. The matrix is huge, ixj = ~2000x2000. Here is my sample code: open(19, file="results1.txt", status="old", position="rewind", & action="write") do j=0,p do i=0,o write(19,*) mat_user_yield_surface(d, eps(i), deps(j), 200.0d0) end do end do close(19) 回答1: Use an implied do loop: do j=0,p write(19,'(2000g22.14)') (mat_user_yield_surface(d, eps(i), deps(j),200

Write matrix with Fortran

半城伤御伤魂 提交于 2019-12-25 16:37:33
问题 I need to output a matrix with FORTRAN. I have a working code that calculates the values, but instead of a matrix, I get single a column. The matrix is huge, ixj = ~2000x2000. Here is my sample code: open(19, file="results1.txt", status="old", position="rewind", & action="write") do j=0,p do i=0,o write(19,*) mat_user_yield_surface(d, eps(i), deps(j), 200.0d0) end do end do close(19) 回答1: Use an implied do loop: do j=0,p write(19,'(2000g22.14)') (mat_user_yield_surface(d, eps(i), deps(j),200

How to find center position of a bitmap that rotated and scaled with a matrix?

隐身守侯 提交于 2019-12-25 14:24:08
问题 I want to calculate center of a bitmap that is drawn on a canvas with a matrix, it can be rotated, scaled or translated with a arbitrary value. What is the easiest way to find center of the this bitmap on canvas? 回答1: You need to apply the matrix to the coordinates of the center of bitmap. If you use a canvas that has a transformation matrix, you can get the final matrix through Canvas.getMatrix() If you draw the Bitmap on the Canvas with a Matrix : drawBitmap(bitmap, matrix, paint) , then

Matrix search operation using numpy and pandas

為{幸葍}努か 提交于 2019-12-25 14:19:10
问题 I am trying to search from one matrix and replace that value on 2nd matrix. ds1 = [[ 4, 13, 6, 9], [ 7, 12, 5, 7], [ 7, 0, 4, 22], [ 9, 8, 12, 0]] ds2 = [[ 4, 1], [ 5, 3], [ 6, 1], [ 7, 2], [ 8, 2], [ 9, 3], [12, 1], [13, 2], [22, 3]] output = [[1, 2, 1, 3], [2, 1, 3, 2], [2, 0, 1, 3], [3, 2, 1, 0]] Here is the code: out = ds1.copy() _,C = np.where(ds1.ravel()[:,None] == ds2[:,0]) newvals = ds2[C,1] valid = np.in1d(ds1.ravel(),ds2[:,0]) out.ravel()[valid] = newvals output is the result of

Different tf-idf values in R and hand calculation

我们两清 提交于 2019-12-25 12:47:50
问题 I am playing around in R to find the tf-idf values. I have a set of documents like: D1 = "The sky is blue." D2 = "The sun is bright." D3 = "The sun in the sky is bright." I want to create a matrix like this: Docs blue bright sky sun D1 tf-idf 0.0000000 tf-idf 0.0000000 D2 0.0000000 tf-idf 0.0000000 tf-idf D3 0.0000000 tf-idf tf-idf tf-idf So, my code in R : library(tm) docs <- c(D1 = "The sky is blue.", D2 = "The sun is bright.", D3 = "The sun in the sky is bright.") dd <- Corpus(VectorSource

Matrix3D for a positive rotation around z in WPF

浪子不回头ぞ 提交于 2019-12-25 12:40:17
问题 Let P be a Point3D such that P = {1,0,0} . I need to define a rotation around the Z axis of +45deg and apply it to P. Under a right-hand convention, the transformation M is defined: M = 0.707 -0.707 0 0 0.707 0.707 0 0 0 0 1 0 0 0 0 1 Mathematically: M x P = 0.707 -0.707 0 0 1 0.707 0.707 0.707 0 0 X 0 = 0.707 0 0 1 0 0 0 0 0 0 1 1 1 here is my C# code: private void testMatrix3D() { double angle_rad = Math.PI/4; double cos = Math.Cos(angle_rad); double sin = Math.Sin(angle_rad); Matrix3D mat

Getting focal length and focal point from a projection matrix

走远了吗. 提交于 2019-12-25 11:57:48
问题 I have a 4x4 projection matrix (SCNMatrix4) s = (m11 = 1.83226573, m12 = 0, m13 = 0, m14 = 0, m21 = 0, m22 = 2.44078445, m23 = 0, m24 = 0, m31 = -0.00576340035, m32 = -0.0016724075, m33 = -1.00019991, m34 = -1, m41 = 0, m42 = 0, m43 = -0.20002, m44 = 0) I would like to get the focal point and the focal length out of this matrix. 回答1: From slides 4 and 5 on this GDC presentation: The focal length is merely the first element in the matrix ( m11 ). The focal point , however, cannot be extracted

How could I add the values of a matrix int[,] diagonally from bottomleft, to topright?

我与影子孤独终老i 提交于 2019-12-25 10:27:20
问题 How could I add the values of a matrix int[,] diagonally from bottomleft, to topright? I'm trying to help out a friend understand this but even I don't really get what they're doing here. Here's the method I'm trying to explain to him: public void AddDiagonal() { int Addition; for (int f = 0; f < filas; f++) { for (int c = 0; c < columnas; c++) { if (f == columnas - c - 1) { Addition += matriz[f, c]; } } } } 回答1: The key to understanding this is the if statement: if (f == columnas - c - 1)

How could I add the values of a matrix int[,] diagonally from bottomleft, to topright?

前提是你 提交于 2019-12-25 10:26:33
问题 How could I add the values of a matrix int[,] diagonally from bottomleft, to topright? I'm trying to help out a friend understand this but even I don't really get what they're doing here. Here's the method I'm trying to explain to him: public void AddDiagonal() { int Addition; for (int f = 0; f < filas; f++) { for (int c = 0; c < columnas; c++) { if (f == columnas - c - 1) { Addition += matriz[f, c]; } } } } 回答1: The key to understanding this is the if statement: if (f == columnas - c - 1)

java--克鲁斯卡尔算法、弗洛伊德算法

一世执手 提交于 2019-12-25 10:25:25
迪杰斯特拉算法 1,应用场景-最短路径问题 2.算法过程 1,设置出发顶点为v,顶点集合为V,v到V的个顶点的距离集合Dis 2,从Dis中选择值最小的di并移出Dis集合,同时移出V集合中对应的顶点vi,此时的v到vi即为最短路径 3,更新Dis,更新规则为:比较v到V集合中顶点的距离值,与v通过vi到V集合中顶点的距离值,保留值较小的一个 4,重复执行,直到最短路径顶点为目标顶点即可结束 public class DijkstraAlgorithm { public static void main ( String [ ] args ) { char [ ] vertex = { 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' } ; //邻接矩阵 int [ ] [ ] matrix = new int [ vertex . length ] [ vertex . length ] ; final int N = 65535 ; //表示不可连接 matrix [ 0 ] = new int [ ] { N , 5 , 7 , N , N , N , 2 } ; matrix [ 1 ] = new int [ ] { 5 , N , N , 9 , N , N , 3 } ; matrix [ 2 ] = new int [ ] { 7 ,