matrix

Understanding output from kmeans clustering in python

余生长醉 提交于 2019-12-25 07:53:46
问题 I have two distance matrices, each 232*232 where the column and row labels are identical. So this would be an abridged version of the two where A, B, C and D are the names of the points between which the distances are measured: A B C D ... A B C D ... A 0 1 5 3 A 0 5 3 9 B 4 0 4 1 B 2 0 7 8 C 2 6 0 3 C 2 6 0 1 D 2 7 1 0 D 5 2 5 0 ... ... The two matrices therefore represent the distances between pairs of points in two different networks. I want to identify clusters of pairs that are close

How to use matrix camera preview left and right reverse on android?

老子叫甜甜 提交于 2019-12-25 07:50:10
问题 I want camera preview left and right reverse, and I search for google, answer is use Matrix is it right answer? first, my source. MainActivity.class private Agen agen = null; protected static Activity mainActivity = null; @Override protected void onCreate(final Bundle savedInstanceState) { agen = new Agen(); agen.CameraSetting(); } public static Activity getMainActivity() { return mainActivity; } Agen.class private CamLiveView camLiveView; private final FrameLayout liveFrame; private final

How to solve singular matrices?

▼魔方 西西 提交于 2019-12-25 07:40:52
问题 I need to solve more than thousand matrices in a list. However, I get the error Lapack routine dgesv: system is exactly singular . My problem is that my input data are non singular matrices, but following the calculations I need to do on the matrices some of them get singular. A reproducible example with a subset of my data is however not possible as it would be to long (I tried already). Here a basic example of my problem (A would be a matrix after some calculations and R the next

glPushMatrix Deprecated, GL30-GL43 Solution? Basic Box example

隐身守侯 提交于 2019-12-25 07:36:11
问题 I'm working on a Program to Render a basic box, but through googling, I have not found a solution for Drawing a face(or group of faces) on screen. Currently every tutorial I've found uses glPushMatrix/glBegin/glEnd/glPopMatrix like this GL11.glPushMatrix(); GL11.glRotatef(pit, 1, 0, 0); GL11.glRotatef(yaw, 0, 1, 0); GL11.glRotatef(rol, 0, 0, 1); GL11.glTranslatef(pos.x, pos.y, pos.z); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad GL11.glVertex3f(

Tensorflow: introducing a matrix of different size in a placeholder

雨燕双飞 提交于 2019-12-25 07:35:26
问题 I'm trying to do a simple operation with tensorflow of matrix multiplication but I have to use a matrix of variable size of its columns (as it can be seen in the example below) import tensorflow as tf input1 = tf.placeholder("float", [None,None]) input2 = tf.placeholder(tf.float32) output = tf.mul(input1, input2) with tf.Session() as sess: print(sess.run([output], feed_dict={input1:[[1,2],[3,4,5]], input2:[2.]})) The thing is that once I do this, I receive an error message telling me:

MATLAB - Perform operation on matrix indices without a for loop

五迷三道 提交于 2019-12-25 07:19:11
问题 It's been a little while since I've done matrix operations in MATLAB, so please forgive me if this is easily solvable. I have some NxM matrix A , and I would like to perform an operation on the column indices of A . I know how to do this using a for loop, but since I'm using MATLAB I'd like to make use of MATLAB's ability to do operations on matrices fast. Suppose I have a function called myFunc . Is there a way to do the following without a for loop (such as with matrix multiplication): for

Inserting elements in a matrix spirally

邮差的信 提交于 2019-12-25 07:18:56
问题 Given a number x, insert elements 1 to x^2 in a matrix spirally. e.g. For x = 3, matrix looks like [[1,2,3],[8,9,4],[7,6,5]]. For this I've written following snippet. However, I'm getting o/p as [[7,9,5],[7,9,5],[7,9,5]] while(t<=b && l<=r){ System.out.print(t+" "+b+" "+l+" "+r+"\n"); if(dir==0){ for(int i = l;i<=r;i++){ arr.get(t).set(i,x); x++; } t++; }else if(dir==1){ for(int i = t;i<=b;i++){ arr.get(i).set(r,x); x++; } r--; }else if(dir==2){ for(int i = r;i>=l;i--){ arr.get(b).set(i,x); x

NetworkX: how to create an incidence matrix of a weighted graph?

旧街凉风 提交于 2019-12-25 07:15:50
问题 Having created a grid network like this: from __future__ import division import networkx as nx from pylab import * import matplotlib.pyplot as plt %pylab inline ncols=10 N=10 #Nodes per side G=nx.grid_2d_graph(N,N) labels = dict( ((i,j), i + (N-1-j) * N ) for i, j in G.nodes() ) nx.relabel_nodes(G,labels,False) inds=labels.keys() vals=labels.values() inds=[(N-j-1,N-i-1) for i,j in inds] pos2=dict(zip(vals,inds)) And having assigned each edge a weight corresponding to its length (in this

How can I evenly space out 2d array in JTextArea without \t?

一笑奈何 提交于 2019-12-25 06:57:31
问题 I ran into a little problem today while I was coding. I'm no expert in java, and I'm only just starting to learn GUI, so bear with me please. I'm creating a game that involves a map that is composed of this 2D array, I've created a method to put that 2D array in a textArea. public void viewMap(String[][] matrix) { for (int r = 0; r < matrix.length; r++) { for (int c = 0; c < matrix[0].length; c++) { textArea.setText(textArea.getText() + "\t" + String.valueOf(matrix[r][c])); } textArea.setText

Save sparse matrix as row, column, and value vectors

[亡魂溺海] 提交于 2019-12-25 06:38:07
问题 I have a sparse matrix saved in a mat file. I want to process it in C++ but my library expects the sparse matrix to be represented as three vectors: colIdx (vector of indices of nonzero columns), rowIdx (vector of indices of nonzero rows), and val (vector of values). How should I go about this? Are there any built-in commands doing similar operations? 回答1: find is what you are looking for [rowIdx colIdx val] = find( myHugeSparseMatrix ); 来源: https://stackoverflow.com/questions/32177489/save