About Store Forum Documentation Contact



Post Reply 
2-dimensional table
Author Message
Harry Offline
Member

Post: #1
2-dimensional table
Hello,

I have small problem with 2-dimensional table. I have to cear some it's values to 0. You can see them on the attachment (x). I know how to clear values below or above the main diagonal but with this I have some problem. Coud you give me some tips?


Attached File(s) Image(s)
   
(This post was last modified: 11-26-2010 11:43 AM by Harry.)
11-26-2010 11:41 AM
Visit this user's website Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #2
RE: 2-dimensional table
Assuming this is gauss so assuming allowed *elementary row operations and no row exchanges

reduced 3x3 example:

PHP Code:
1 1 1
x 1 1
x x 1

1    1    1 
0    1
-x 1-x
0    0    1
-x

1    1    1
0    1
-x 0
0    0    1
-x

1    0    0
0    1
-x 0        Row Operation (R1 R2*(1/(1-x)) - R3*(1/(1-x)))
0    0    1-

4x4

PHP Code:
1 1 1 1
x 1 1 1
x x 1 1
x 1 1 1

1    1    1    1
0    1
-x 1-x 1-x
0    0    1
-x 1-x
0    1
-x 1-x 1-x

1    1    1    1
0    1
-x 1-x 1-x
0    0    1
-x 1-x
0    1
-x 1-x 1-x

1    1    1    1
0    1
-x  0   0
0    0    1
-x 1-x
0    1
-x  0   0

1    1    1    1
0    1
-x 0    0
0    0    1
-x 1-x
0    0    0    0

1    0    0    0
0    1
-x 0    0
0    0    1
-x 1-x
0    0    0    0 


and etc for nxn matrices

You can also see that R2 can null out R10, R3 can null out R9, etc effectively giving you rows 1-6 and with rows 7-10 being all zeros.
(This post was last modified: 11-26-2010 02:19 PM by llynx.)
11-26-2010 12:07 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #3
RE: 2-dimensional table
I don't know what Gaussian transformations exactly are (you mean this: http://en.wikipedia.org/wiki/Gaussian_elimination ?) but if I undestand your examples well after celaring elements which I ticked by X rest of elements can change their values? I don't want to have this. Fo example whole elements of table has a random number and I want set to 0 only elements which I ticked by X.

Here is an example of clearing elements under main diagonal:


Attached File(s) Image(s)
   
(This post was last modified: 11-26-2010 01:38 PM by Harry.)
11-26-2010 01:37 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #4
RE: 2-dimensional table
Isn't it just a simple case of having the right If statement then, when iterating the cells:

Int n = Table.dimensions();

FREPD(x,n) FREPD(y,n) {

if (y>x && y<n-x && x<n/2)
Cell(x,y) = 0;
else
Cell(x,y) = 1;
}

Note this is unchecked, you may need to debug it and slightly change the if statement. But the idea is that you count the row your on (x) then check if the y element is greater then x (+ mirror it) so check if its less than count-x. You may not need the third && - but you can only do this for half of it, by doing x <= n/2 etc.
11-26-2010 02:03 PM
Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #5
RE: 2-dimensional table
Hahaha I thought this was a linear algebra problem pfft and you were doing matrix row ops to clear cells

Chris is right for the programming example if you just want to set the values to zero
11-26-2010 02:17 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #6
RE: 2-dimensional table
Ok i get it. I didn't properly wrote the second condition. Thank you both for help.
(This post was last modified: 11-26-2010 02:24 PM by Harry.)
11-26-2010 02:23 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply