Here's a Perl solution for the type of data you posted:
I think summer_cherry's program is a much more optimized version. It -
(i) does not store the entire N X N square matrix in any data structure.
(ii) stores only the information present in the file, since that is sufficient to generate the other half of the square matrix.
(iii) uses hashes for fast access.
My second version uses a multi-dimensional array to store only the necessary information i.e. everything after the "id" and "1.000" per element. It also keeps on chopping the array element right after it is printed, by using the "shift" operator. So while the run time would be higher for this, the memory consumption should be lesser.
HTH,
tyler_durden
This User Gave Thanks to durden_tyler For This Post:
Hi All
I would like to merge multiple files with the same row and column size into a matrix format
In a folder I have multiple files in the following format
vi 12.txt
a 1
b 5
c 7
d 0
vi 45.txt
a 3
b 6
c 9
d 2
vi 9.txt
a 4 (7 Replies)
Hi all,
Is there a way to convert full data matrix to linearised left data matrix?
e.g full data matrix
Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7
Bh1 0 0.241058 0.236129 0.244397 0.237479 0.240767 0.245245
Bh2 0.241058 0 0.240594 0.241931 0.241975 ... (8 Replies)
Hi everyone
I am very new at awk but think that that might be the best strategy for this. I have a matrix very similar to a correlation matrix and in practical terms I need to convert it into a list containing the values from the matrix (one value per line) with the first field of the line (row... (5 Replies)
Hi,
I have a table in the format:
1 0 -1 1 0
2 0 1 -1 0 0 0
3 0 1 1 0 0 0 0 0 0
etc.
I am trying to input this to a program, however it is complaining about the fact that it is not in matrix format. How do I add 0's to end of the rows to make them even?
Thanks in advance! (2 Replies)
Hello all,
I am quite new in this but I need some help to keep going with my analysis.
I am struggling with a short script to read a square matrix and convert it in two collumns.
A B C D
A 0.00 0.06 0.51 0.03
B 0.06 0.00 0.72 0.48
C 0.51 0.72 0.00 ... (7 Replies)
Hi Experts,
I want to print this charts diagonal data into straight lines.
This is a matrix 24X24 Horizontal and vertical.
- I want to print all the diagonal cutting characters into straight line:
Data:
E F S S A H A L L A T M C N O T S O B O D U Q H
I W I B N L O C N I L N L A N S I N... (9 Replies)
Hello friends,
A big question for the UNIX INTELLIGENCE
I have a CSV file as follows:
VALUE,USER1,relatedUSER1,relatedUSER2
-1,userA,userB,userC
1,userN,userD,userB
0,userF,userH,userG
0,userT,userH,userB
1,userN,userB,userA
-1,userA,userF,userC
0,userF,userH,userG... (15 Replies)
I have two files. Row id in File1 matches the column id in file2 (starting from column7 )except the last 2 characters. File1 has 50 rows and File 2 has 56 columns. If the id matches I want to multiply the value in column3 of File1 to the entire column in File2. and in the final output print only... (11 Replies)
Discussion started by: Akang
11 Replies
LEARN ABOUT CENTOS
slaset.f
slaset.f(3) LAPACK slaset.f(3)NAME
slaset.f -
SYNOPSIS
Functions/Subroutines
subroutine slaset (UPLO, M, N, ALPHA, BETA, A, LDA)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Function/Subroutine Documentation
subroutine slaset (characterUPLO, integerM, integerN, realALPHA, realBETA, real, dimension( lda, * )A, integerLDA)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Purpose:
SLASET initializes an m-by-n matrix A to BETA on the diagonal and
ALPHA on the offdiagonals.
Parameters:
UPLO
UPLO is CHARACTER*1
Specifies the part of the matrix A to be set.
= 'U': Upper triangular part is set; the strictly lower
triangular part of A is not changed.
= 'L': Lower triangular part is set; the strictly upper
triangular part of A is not changed.
Otherwise: All of the matrix A is set.
M
M is INTEGER
The number of rows of the matrix A. M >= 0.
N
N is INTEGER
The number of columns of the matrix A. N >= 0.
ALPHA
ALPHA is REAL
The constant to which the offdiagonal elements are to be set.
BETA
BETA is REAL
The constant to which the diagonal elements are to be set.
A
A is REAL array, dimension (LDA,N)
On exit, the leading m-by-n submatrix of A is set as follows:
if UPLO = 'U', A(i,j) = ALPHA, 1<=i<=j-1, 1<=j<=n,
if UPLO = 'L', A(i,j) = ALPHA, j+1<=i<=m, 1<=j<=n,
otherwise, A(i,j) = ALPHA, 1<=i<=m, 1<=j<=n, i.ne.j,
and, for all UPLO, A(i,i) = BETA, 1<=i<=min(m,n).
LDA
LDA is INTEGER
The leading dimension of the array A. LDA >= max(1,M).
Author:
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date:
September 2012
Definition at line 111 of file slaset.f.
Author
Generated automatically by Doxygen for LAPACK from the source code.
Version 3.4.2 Tue Sep 25 2012 slaset.f(3)