matrix

Division of sparse matrix

半城伤御伤魂 提交于 2020-01-19 17:39:12
问题 I have a scipy.sparse matrix with 45671x45671 elements. In this matrix, some rows contain only '0' value. My question is, how to divide each row values by the row sum. Obviously, with for loop it's work, but I look for an efficient method... I already tried : matrix / matrix.sum(1) but I have MemoryError issue. matrix / scs.csc_matrix((matrix.sum(axis=1))) but ValueError: inconsistent shapes Other wacky things... Moreover, I want to skip rows with only '0' values. So, if you have any solution

gnuplot: label x and y-axis of matrix (heatmap) with row and column names

别等时光非礼了梦想. 提交于 2020-01-19 10:09:11
问题 I'm absolutely new to gnuplot and did not find a working solution after googling. I have a data matrix looking something like this: A B C D E A 0 2 3 4 5 B 6 0 8 9 0 C 1 2 0 4 5 D 6 7 8 0 0 E 1 2 3 4 0 What I would like to do is plotting a heatmap with plot 'result.csv' matrix with image , with the x-axis labeled with A-E and the y-axis labeled with A-E. This matrix does not always have the same size, but the number of row always equals the number of cols and it's always labeled. Could

gnuplot: label x and y-axis of matrix (heatmap) with row and column names

旧巷老猫 提交于 2020-01-19 10:08:10
问题 I'm absolutely new to gnuplot and did not find a working solution after googling. I have a data matrix looking something like this: A B C D E A 0 2 3 4 5 B 6 0 8 9 0 C 1 2 0 4 5 D 6 7 8 0 0 E 1 2 3 4 0 What I would like to do is plotting a heatmap with plot 'result.csv' matrix with image , with the x-axis labeled with A-E and the y-axis labeled with A-E. This matrix does not always have the same size, but the number of row always equals the number of cols and it's always labeled. Could

gnuplot: label x and y-axis of matrix (heatmap) with row and column names

筅森魡賤 提交于 2020-01-19 10:06:05
问题 I'm absolutely new to gnuplot and did not find a working solution after googling. I have a data matrix looking something like this: A B C D E A 0 2 3 4 5 B 6 0 8 9 0 C 1 2 0 4 5 D 6 7 8 0 0 E 1 2 3 4 0 What I would like to do is plotting a heatmap with plot 'result.csv' matrix with image , with the x-axis labeled with A-E and the y-axis labeled with A-E. This matrix does not always have the same size, but the number of row always equals the number of cols and it's always labeled. Could

Extracting off-diagonal slice of large matrix

妖精的绣舞 提交于 2020-01-19 07:37:05
问题 I've got a large nxn matrix and would like to take off-diagonal slices of varying sizes. For example: 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 I'd like an R function which, when given the matrix and "width of diagonal slice" would return an nxn matrix of just those values. So for the matrix above and, say, 3, I'd get: 1 x x x x x 1 2 x x x x 1 2 3 x x x x 2 3 4 x x x x 3 4 5 x x x x 4 5 6 At the moment I'm using (forgive me) a for loop which is incredibly slow:

Extracting off-diagonal slice of large matrix

南楼画角 提交于 2020-01-19 07:36:28
问题 I've got a large nxn matrix and would like to take off-diagonal slices of varying sizes. For example: 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 I'd like an R function which, when given the matrix and "width of diagonal slice" would return an nxn matrix of just those values. So for the matrix above and, say, 3, I'd get: 1 x x x x x 1 2 x x x x 1 2 3 x x x x 2 3 4 x x x x 3 4 5 x x x x 4 5 6 At the moment I'm using (forgive me) a for loop which is incredibly slow:

Extract arbitrarily rotated plane of data from 3D array as 2D array

孤街浪徒 提交于 2020-01-19 04:00:08
问题 I have a 3D matrix of data in matlab, but I want to extract an arbitrarily rotated slice of data from that matrix and store it as a 2D matrix, which I can access. Similar to how the slice() function displays data sliced at any angle, except I would also like to be able to view and modify the data as if it were an array. I have the coordinates of the pivot-point of the plane as well as the angles of rotation (in x, y and z axis), I have also calculated the equation of the plane in the form: Ax

将正方形矩阵顺时针旋转90度

北战南征 提交于 2020-01-19 00:36:09
题目 给定一个矩阵matrix,把矩阵顺时针转动90度: 1 2 3 4 5 6 7 8 9 -> 7 4 1 8 5 2 9 6 3 思路 比较简单的思路 1)先上下对称 -> 7 8 9 4 5 6 1 2 3 2)对角互换 -> 7 4 1 8 5 2 9 6 3 实现 def rotate ( matrix ) : if matrix is None or len ( matrix ) == 0 or len ( matrix [ 0 ] ) != len ( matrix ) : return size = len ( matrix ) for i in range ( size // 2 ) : matrix [ i ] , matrix [ size - i - 1 ] = matrix [ size - i - 1 ] , matrix [ i ] for i in range ( size ) : for j in range ( i ) : matrix [ i ] [ j ] , matrix [ j ] [ i ] = matrix [ j ] [ i ] , matrix [ i ] [ j ] return matrix 测试 def test_rotate ( size ) : n = 1 mat = [ ] for i in range ( size

TextureView播放本地视频

耗尽温柔 提交于 2020-01-18 03:56:10
1.效果图: 2.清单文件:文件读取权限 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 3.主界面: package com.example.administrator.testz; import androidx.appcompat.app.AppCompatActivity; import android.graphics.Matrix; import android.graphics.SurfaceTexture; import android.media.MediaPlayer; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.Surface; import android.view.TextureView; import java.io.IOException; public class MainActivity extends AppCompatActivity implements TextureView.SurfaceTextureListener, MediaPlayer.OnPreparedListener

Shader预处理宏、内置状态变量、多版本编译等

你。 提交于 2020-01-18 01:05:33
预定义shader预处理宏:   Target platform:   SHADER_API_OPENGL - desktop OpenGL   SHADER_API_D3D9 - Direct3D 9   SHADER_API_XBOX360 - Xbox 360   SHADER_API_PS3 - PlayStation 3   SHADER_API_D3D11 - desktop Direct3D 11   SHADER_API_GLES - OpenGL ES 2.0 (desktop or mobile), use presence of SHADER_API_MOBILE to determine.   SHADER_API_FLASH - Flash Stage3D   SHADER_API_D3D11_9X - Direct3D 11 target for Windows RT   Surface shader pass indicators:   UNITY_PASS_FORWARDBASE - 前向渲染的base pass(主方向光、lightmaps、SH)   UNITY_PASS_FORWARDADD - 前向渲染的add pass(没盏灯一个pass)   UNITY_PASS_PREPASSBASE - 延迟渲染base pass(renders