Sponsored Content
Full Discussion: In place matrix operations
Top Forums UNIX for Dummies Questions & Answers In place matrix operations Post 302926237 by RudiC on Saturday 22nd of November 2014 05:55:12 AM
Old 11-22-2014
Try
Code:
awk     'FNR==NR        {for(i=1; i<=NF; i++) T[FNR,i]=$i; next}
         FNR==1         {print; next}
                        {printf "%s%s", $1, FS
                         for(i=2; i<=NF; i++) printf("%2.0f%s", $i*T[FNR,i], (i==NF) ? "\n" : FS);
                        }
        ' file1 file2
- a b
a  5 12
b 21 32

Increase the %f's field length if need be.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File operations

Hi there, I want some help on scripting regarding file processing. I have a scenario in which I have 10 files. (file1.txt, file2.txt....) and they are in paricular format. I want to read these files and append some text lines at the begining of each file and write this updated contents of... (2 Replies)
Discussion started by: chiragmistry21
2 Replies

2. Shell Programming and Scripting

String Operations

Hi All, Query 1 : I want to know how we can get a count of multipe occurrences of a particular expression in another string. For Eg. If my string is " 12" and i need to count the number of spaces preceeding 12 Query 2 : Also want to know how we can change the alignment of a... (9 Replies)
Discussion started by: Rohini Vijay
9 Replies

3. UNIX for Dummies Questions & Answers

File operations

Hi I have a tab delimited file with 3 fields. I need to sort this file on the first field and remove all the records where the first field has dulplicates. For eg my file is 133|arrfdfdg|sdfdsg 234|asfsdgfs|aasdfs 133|affbfsde|dgfg When this file gets sorted I need the result to be ... (2 Replies)
Discussion started by: monks
2 Replies

4. Shell Programming and Scripting

Matrix Operations of two files

Hi , I have two files aaa.txt (which contains) 1 2 3 4 5 6 7 8 9 10 11 12 and bbb.txt (which contains) -1 -2 -3 -4 -5 -6 5 -8 0 3 0 0 the output that I intended to have is 0 0 0 0 0 0 6 0 4.5 6.5 5.5 6 i.e. Averaging the script is in the file abc Begin{START of the... (2 Replies)
Discussion started by: narendra_linux
2 Replies

5. Shell Programming and Scripting

diagonal matrix to square matrix

Hello, all! I am struggling with a short script to read a diagonal matrix for later retrieval. 1.000 0.234 0.435 0.123 0.012 0.102 0.325 0.412 0.087 0.098 1.000 0.111 0.412 0.115 0.058 0.091 0.190 0.045 0.058 1.000 0.205 0.542 0.335 0.054 0.117 0.203 0.125 1.000 0.587 0.159 0.357... (11 Replies)
Discussion started by: yifangt
11 Replies

6. Solaris

What is the best way to copy data from place to another place?

Dear Gurus, I need you to advice or suggestion about the best solution to copy data around 200-300G from serverA(location A) to serverB(location B). Normally, I will share folder and then copy but it takes too long time(about 2 days). Do you have any suggestion or which way should be... (9 Replies)
Discussion started by: unitipon
9 Replies

7. Ubuntu

How to convert full data matrix to linearised left data matrix?

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)
Discussion started by: evoll
8 Replies

8. Shell Programming and Scripting

awk? adjacency matrix to adjacency list / correlation matrix to list

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)
Discussion started by: stonemonkey
5 Replies

9. Shell Programming and Scripting

Shell operations from C++

Hi everyone, I need little help in shell operations from C++ program. Here I furnish the details of problem: 1. Lets say my current working path is myWorkingPath. 2. In my working path I have list of name directories and each name directory has two more sub directories say A/B. (now path to... (5 Replies)
Discussion started by: linuxUser_
5 Replies

10. Shell Programming and Scripting

Where to place operations bash scripts?

As I have sometimes problems with passenger module loading correctly after restart of apache2 we wrote a short bash-script to check correct loading of application (redmine) and - if not- restarting apache2 until application is loaded by passenger. Script is invoked using cron. To do everything... (2 Replies)
Discussion started by: awilhelmy
2 Replies
GLMULTMATRIX(3G)														  GLMULTMATRIX(3G)

NAME
glMultMatrixd, glMultMatrixf - multiply the current matrix with the specified matrix C SPECIFICATION
void glMultMatrixd( const GLdouble *m ) void glMultMatrixf( const GLfloat *m ) PARAMETERS
m Points to 16 consecutive values that are used as the elements of a 4x4 column-major matrix. DESCRIPTION
glMultMatrix multiplies the current matrix with the one specified using m, and replaces the current matrix with the product. The current matrix is determined by the current matrix mode (see glMatrixMode). It is either the projection matrix, modelview matrix, or the texture matrix. EXAMPLES
If the current matrix is C, and the coordinates to be transformed are, v=(v[0],v[1],v[2],v[3]). Then the current transformation is Cxv, or c[0] c[4] c[8] c[12] v[0] (c[1] c[5] c[9] c[13])x(v[1]) c[2] c[6] c[10] c[14] v[2] c[3] c[7] c[11] c[15] v[3] Calling glMultMatrix with an argument of m=m[0],m[1],...,m[15] replaces the current transformation with (CxM)xv, or c[0] c[4] c[8] c[12] m[0] m[4] m[8] m[12] v[0] (c[1] c[5] c[9] c[13])x(m[1] m[5] m[9] m[13])x(v[1]) c[2] c[6] c[10] c[14] m[2] m[6] m[10] m[14] v[2] c[3] c[7] c[11] c[15] m[3] m[7] m[11] m[15] v[3] Where 'x' denotes matrix multiplication, and v is represented as a 4x1 matrix. NOTES
While the elements of the matrix may be specified with single or double precision, the GL may store or operate on these values in less than single precision. In many computer languages 4x4 arrays are represented in row-major order. The transformations just described represent these matrices in column-major order. The order of the multiplication is important. For example, if the current transformation is a rotation, and glMultMatrix is called with a translation matrix, the translation is done directly on the coordinates to be transformed, while the rotation is done on the results of that translation. ERRORS
GL_INVALID_OPERATION is generated if glMultMatrix is executed between the execution of glBegin and the corresponding execution of glEnd. ASSOCIATED GETS
glGet with argument GL_MATRIX_MODE glGet with argument GL_COLOR_MATRIX glGet with argument GL_MODELVIEW_MATRIX glGet with argument GL_PROJECTION_MATRIX glGet with argument GL_TEXTURE_MATRIX SEE ALSO
glLoadIdentity(3G), glLoadMatrix(3G), glMatrixMode(3G), glPushMatrix(3G) GLMULTMATRIX(3G)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy