matrix

Linear Programming with Big Matrix - Still having memory problems

只愿长相守 提交于 2020-01-17 04:25:30
问题 Hello everyone and thanks in advance! I've had a bit of an interesting journey with this problem. Here I figured out how to create a file-backed big matrix using the bigmemory package. This 7062 row by 364520 column matrix is the constraint matrix in a linear programming problem I'm trying to solve using the Rsymphony package. The code is below and the constraint matrix is called mat : Rsymph <- Rsymphony_solve_LP(obj ,mat[1:nrow(mat),1:ncol(mat)] ,dir ,rhs ,types="B",max=F, write_lp=T)

Referencing entries of matrix in R within for loop

你说的曾经没有我的故事 提交于 2020-01-17 03:03:31
问题 Is there a way to reference a part of a matrix within a for loop? for (j in 1:x1) for (k in 1:x2) { matrix[j,8k-6:8k+1] <- AlleleFreq.t1[k,1:8] } } I get an error message saying "unexpected symbol in "alldata.t1[j,8k". What is the correct syntax for preforming this sort of operation? Thank you. 回答1: use parens & * to multiply: 8k-6:8k+1 ~~~> (8*k-6):(8*k+1) the seq operator : takes precedence over arithmetic operators such as - Thus, without parens, you have (8*k) - c(6, 7, 8) + ((8*k) + 1)

how to run chisq.test in loops using apply

好久不见. 提交于 2020-01-16 19:14:19
问题 I am a newbie of R. Due to the need of my project, I need to do Chisq test for hundred thousand entries. I learned by myself for a few days and write some code for runing chisq.test in loops. codes: the.data = read.table ("test_chisq_allelefrq.txt", header=T, sep="\t",row.names=1) p=c() ID=c() for (i in 1:nrow(the.data)) { data.row = the.data [i,] data.matrix = matrix ( c(data.row$cohort_1_AA, data.row$cohort_1_AB, data.row$cohort_1_BB, data.row$cohort_2_AA, data.row$cohort_2_AB, data.row

R - Create a ordered list from a matrix

丶灬走出姿态 提交于 2020-01-16 18:39:33
问题 Hi there! I have this 24x24 matrix with a lot of numbers from 1-24. Where I want to turn every cell with the value of X (eg. 3) into the row.name of the X'th row (eg. name3) What I have row.names V1 V2 V3 name1 1 3 10 name2 3 20 1 name3 5 13 2 ... .. .. .. name24 19 3 4 What I want to do now, is turn all these numbers into a character string equvivalent to the i'th row name so a 1 should be converted to name1 and so forth. What I need row.names V1 V2 V3 name1 name1 name3 name10 name2 name3

Algorithm for Finding Longest Stretch of a Value at any Angle in a 2D Matrix

我是研究僧i 提交于 2020-01-16 18:18:31
问题 I am currently working on a computer-vision program that requires me to determine the "direction" of a color blob in an image. The color blob generally follows an elliptical shape and thus can be used to track direction (with respect to an initially defined/determined orientation) through time. The means by which I figured I would calculate changes in direction are described as follows: Quantize possible directions (360 degrees) into N directions (potentially 8, for 45 degree angle increments

Fortran- Inverse Matrix result not same if Decimal is longer

房东的猫 提交于 2020-01-16 16:09:11
问题 My real data is first input but inverse of result is so big. They are same data when you compare with first and second input. There is only difference decimal size. Why is there different result? Because they are same data. How can they have different result? You can see result and input. It is so strange. program test Implicit none double precision,allocatable,dimension(:,:) :: A double precision,allocatable,dimension(:) :: WORK integer ,allocatable,dimension(:) :: ipiv integer :: n,info,M

Fortran- Inverse Matrix result not same if Decimal is longer

孤街醉人 提交于 2020-01-16 16:08:45
问题 My real data is first input but inverse of result is so big. They are same data when you compare with first and second input. There is only difference decimal size. Why is there different result? Because they are same data. How can they have different result? You can see result and input. It is so strange. program test Implicit none double precision,allocatable,dimension(:,:) :: A double precision,allocatable,dimension(:) :: WORK integer ,allocatable,dimension(:) :: ipiv integer :: n,info,M

octave error undefined near line 1 column 1

北战南征 提交于 2020-01-16 14:37:34
问题 I try to read a matrix from a file. The code is very simple function [mat] = read(file) mat = load(file_points) But when I try to run it read('file') mat = scalar structure containing the fields: mat = 3 4 6 3 5 1 it shows the matrix, but when I run this command... >>mat(1,1) error: 'points' undefined near line 1 column 1 回答1: From Octave Forge about load() If invoked with a single output argument, Octave returns data instead of inserting variables in the symbol table. If the data file

CSS 2D、3D 转换

核能气质少年 提交于 2020-01-16 13:08:07
一、CSS3 转换 通过 CSS3 转换,我们能够对元素进行移动、缩放、转动、拉长或拉伸。 浏览器支持 Internet Explorer 10、以及 Opera 支持 transform 属性。 注释:Internet Explorer 9 需要前缀 -ms-。 Chrome 和 Safari 需要前缀 -webkit-。 二、2D 转换 在本章中,您将学到如下 2D 转换方法: translate() rotate() scale() skew() matrix() 1、translate() 转换:沿着 X 和 Y 轴移动元素。 通过 translate() 方法,元素从其当前位置移动,根据给定的 left(x 坐标) 和 top(y 坐标) 位置参数: 值 translate(50px,100px) 把元素从左侧移动 50 像素,从顶端移动 100 像素。 div { transform: translate(50px,100px); -ms-transform: translate(50px,100px); /* IE 9 */ -webkit-transform: translate(50px,100px); /* Safari and Chrome */ -o-transform: translate(50px,100px); /* Opera */ -moz

How to combine two 2D array into the following in Python?

假装没事ソ 提交于 2020-01-16 11:59:08
问题 Suppose I have 2 2D array as follows: A = [[1, 2], [3, 4]] B = [[5, 6, 7], [8, 9, 8], [7, 6, 5]] Is there a numpy function to combine A and B into C as follows? C = [[1, 2, 0, 0, 0], [3, 4, 0, 0, 0], [0, 0, 5, 6, 7], [0, 0, 8, 9, 8], [0, 0, 7, 6, 5]] Thanks 回答1: If you expect to be making many linear algebraic operations, NumPy/SciPy will be your friend. For the particular problem of creating block diagonal matrices, scipy.linalg.block_diag saves the day: In [14]: from scipy.linalg import