[Scilab-users] submatrix issue

classic Classic list List threaded Threaded
8 messages Options
Carrico, Paul Carrico, Paul
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] submatrix issue

Dear all

I’ve a submatrix issue on the following example, and I do not remember (or understand) why : how can I do this ?

(the goal is to extract and to store within a matrix results from an Ascii file)

Thanks for any help

Paul

###############################################################

mode(0)

clear all

 

StartNodeLine = 1;

NumberOfNodes = 100;

DimCoordinates = 3;

resu = rand(1000,1);

 

tic();

NodesMatrix2 = zeros(NumberOfNodes,DimCoordinates+1);

i = [1 : NumberOfNodes]'; NodesMatrix2(i,1) = evstr(resu(StartNodeLine + (DimCoordinates+2)*(i-1)+2));

i = [1 : NumberOfNodes]'.*.ones(1,DimCoordinates)';

j = ones(1,NumberOfNodes)'.*.[1 : DimCoordinates]';

k = StartNodeLine + (DimCoordinates+2)*(i-1)+3+j;

 

a = evstr(resu(k));

 

NodesMatrix2(i,j+1) = evstr(resu(k)); // does not work

//NodesMatrix2(i,j+1) = 1; // work(basic assignement)

Duration2 = toc()

 

 

 

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data

 


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: submatrix issue

It cannot work since

--> size(k)
 ans  =

   300.   1.


--> length(i)*length(j)
 ans  =

   90000.

i.e. NodesMatrix2(i,j+1) has 90000 elements and resu(k) has 300

S.

Le 01/06/2018 à 11:07, Carrico, Paul a écrit :

Dear all

I’ve a submatrix issue on the following example, and I do not remember (or understand) why : how can I do this ?

(the goal is to extract and to store within a matrix results from an Ascii file)

Thanks for any help

Paul

###############################################################

mode(0)

clear all

 

StartNodeLine = 1;

NumberOfNodes = 100;

DimCoordinates = 3;

resu = rand(1000,1);

 

tic();

NodesMatrix2 = zeros(NumberOfNodes,DimCoordinates+1);

i = [1 : NumberOfNodes]'; NodesMatrix2(i,1) = evstr(resu(StartNodeLine + (DimCoordinates+2)*(i-1)+2));

i = [1 : NumberOfNodes]'.*.ones(1,DimCoordinates)';

j = ones(1,NumberOfNodes)'.*.[1 : DimCoordinates]';

k = StartNodeLine + (DimCoordinates+2)*(i-1)+3+j;

 

a = evstr(resu(k));

 

NodesMatrix2(i,j+1) = evstr(resu(k)); // does not work

//NodesMatrix2(i,j+1) = 1; // work(basic assignement)

Duration2 = toc()

 

 

 

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data

 



_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users


-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Antoine Monmayrant Antoine Monmayrant
Reply | Threaded
Open this post in threaded view
|

Re: submatrix issue

Hello,


What do you wan to achieve exactly?
As Stéphane pointed out, the sizes are not the same.
When you assign something like:

A=B;

You have two different situations:

1) size(A)==size(B)
2) size(B)=[1,1]

In the first case, you assign each element of B to each element of A. In the latter case (which corresponds to your commented line), B is just a scalar that gets assigned to each element of A.

In the current situation, you are neither in case 1) nor in case 2).
As you have size(NodesMatrix2(i,j+1))=[300,300] and size(resu(k))=[300,1], you might want to replicate resu(k) 300 times and fill NodesMatrix2(i,j+1) with these 300 copies. If this what you want to do, here is the code:

NodesMatrix2(i,j+1)=resu(k)*ones(1,300);


By the way, why do you use "evstr(resu(k))" instead of "resu(k)"?


Antoine


Le 01/06/2018 à 11:45, Stéphane Mottelet a écrit :
It cannot work since

--> size(k)
 ans  =

   300.   1.


--> length(i)*length(j)
 ans  =

   90000.

i.e. NodesMatrix2(i,j+1) has 90000 elements and resu(k) has 300

S.

Le 01/06/2018 à 11:07, Carrico, Paul a écrit :

Dear all

I’ve a submatrix issue on the following example, and I do not remember (or understand) why : how can I do this ?

(the goal is to extract and to store within a matrix results from an Ascii file)

Thanks for any help

Paul

###############################################################

mode(0)

clearall

StartNodeLine= 1;

NumberOfNodes= 100;

DimCoordinates= 3;

resu= rand(1000,1);

tic();

NodesMatrix2= zeros(NumberOfNodes,DimCoordinates+1);

i= [1 : NumberOfNodes]'; NodesMatrix2(i,1) = _evstr_(resu(StartNodeLine + (DimCoordinates+2)*(i-1)+2));

i= [1 : NumberOfNodes]'.*.ones(1,DimCoordinates)';

j= ones(1,NumberOfNodes)'.*.[1 : DimCoordinates]';

k= StartNodeLine + (DimCoordinates+2)*(i-1)+3+j;

a= _evstr_(resu(k));

NodesMatrix2(i,j+1)= _evstr_(resu(k)); /// does not work/

///NodesMatrix2(i,j+1) = 1; // work(basic assignement)/

Duration2= toc()

*/EXPORT CONTROL :
/**Cet email ne contient pas de données techniques
This email does not contain technical data*



_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users




_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Carrico, Paul Carrico, Paul
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Re: submatrix issue

In reply to this post by mottelet

Thanks Stephane for your answer, nonetheless:

 

size i = size j = size k = 300. 1.

 

And if you uncomment the line with assignment to 1, the final size is (100x4) as expected

//NodesMatrix2(i,j+1) = 1; // work(basic assignment)

 

Am I wrong to think that “evstr(resu(k)” assign the n th value of the k vector ? it has worked for “NodesMatrix2(i,j+1)” …

 

Paul

###########################

mode(0)

clear all

 

StartNodeLine = 1;

NumberOfNodes = 100;

DimCoordinates = 3;

resu = rand(1000,1);

 

tic();

NodesMatrix2 = zeros(NumberOfNodes,DimCoordinates+1);

//i = [1 : NumberOfNodes]'; NodesMatrix2(i,1) = evstr(resu(StartNodeLine + (DimCoordinates+2)*(i-1)+2));

i = [1 : NumberOfNodes]'.*.ones(1,DimCoordinates)';

j = ones(1,NumberOfNodes)'.*.[1 : DimCoordinates]';

k = StartNodeLine + (DimCoordinates+2)*(i-1)+3+j;

 

a = evstr(resu(k));

 

//NodesMatrix2(i,j+1) = evstr(resu(k)); // does not work

NodesMatrix2(i,j+1) = 1; // work

Duration2 = toc()

 

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data

 

De : users [mailto:[hidden email]] De la part de Stéphane Mottelet
Envoyé : vendredi 1 juin 2018 11:45
À : [hidden email]
Objet : [EXTERNAL] Re: [Scilab-users] submatrix issue

 

It cannot work since

--> size(k)
 ans  =

   300.   1.


--> length(i)*length(j)
 ans  =

   90000.

i.e. NodesMatrix2(i,j+1) has 90000 elements and resu(k) has 300

S.

Le 01/06/2018 à 11:07, Carrico, Paul a écrit :

Dear all

I’ve a submatrix issue on the following example, and I do not remember (or understand) why : how can I do this ?

(the goal is to extract and to store within a matrix results from an Ascii file)

Thanks for any help

Paul

###############################################################

mode()

clear all

 

StartNodeLine = 1;

NumberOfNodes = 100;

DimCoordinates = 3;

resu = rand(1000,1);

 

tic();

NodesMatrix2 = zeros(NumberOfNodes,DimCoordinates+1);

i = [1 : NumberOfNodes]'; NodesMatrix2(i,1) = evstr(resu(StartNodeLine + (DimCoordinates+2)*(i-1)+2));

i = [1 : NumberOfNodes]'.*.ones(1,DimCoordinates)';

j = ones(1,NumberOfNodes)'.*.[1 : DimCoordinates]';

k = StartNodeLine + (DimCoordinates+2)*(i-1)+3+j;

 

a = evstr(resu(k));

 

NodesMatrix2(i,j+1) = evstr(resu(k)); // does not work

//NodesMatrix2(i,j+1) = 1; // work(basic assignement)

Duration2 = toc()

 

 

 

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data

 




_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users

 

-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Carrico, Paul Carrico, Paul
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Re: submatrix issue

In reply to this post by Antoine Monmayrant

Evstr(resu(k)) is a paste error - I’m reading an asci file J

Without using a loop, I would like to get the n th component of the vector resu(k) … k is no more no less than the index of specific lines I’m trying to get …

Through your answers I’m understanding that I’m thinking on a bad way

Paul

 

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data

 

De : users [mailto:[hidden email]] De la part de antoine monmayrant
Envoyé : vendredi 1 juin 2018 11:55
À : [hidden email]
Objet : [EXTERNAL] Re: [Scilab-users] submatrix issue

 

Hello,

 

What do you wan to achieve exactly?
As Stéphane pointed out, the sizes are not the same.
When you assign something like:

A=B;

You have two different situations:

1) size(A)==size(B)
2) size(B)=[1,1]

In the first case, you assign each element of B to each element of A. In the latter case (which corresponds to your commented line), B is just a scalar that gets assigned to each element of A.

In the current situation, you are neither in case 1) nor in case 2).
As you have size(NodesMatrix2(i,j+1))=[300,300] and size(resu(k))=[300,1], you might want to replicate resu(k) 300 times and fill NodesMatrix2(i,j+1) with these 300 copies. If this what you want to do, here is the code:

NodesMatrix2(i,j+1)=resu(k)*ones(1,300);

 

By the way, why do you use "evstr(resu(k))" instead of "resu(k)"?

 

Antoine

 

Le 01/06/2018 à 11:45, Stéphane Mottelet a écrit :

It cannot work since

--> size(k)
 ans  =

   300.   1.


--> length(i)*length(j)
 ans  =

   90000.

i.e. NodesMatrix2(i,j+1) has 90000 elements and resu(k) has 300

S.

Le 01/06/2018 à 11:07, Carrico, Paul a écrit :


Dear all

I’ve a submatrix issue on the following example, and I do not remember (or understand) why : how can I do this ?

(the goal is to extract and to store within a matrix results from an Ascii file)

Thanks for any help

Paul

###############################################################

mode(0)

clearall

StartNodeLine= 1;

NumberOfNodes= 100;

DimCoordinates= 3;

resu= rand(1000,1);

tic();

NodesMatrix2= zeros(NumberOfNodes,DimCoordinates+1);

i= [1 : NumberOfNodes]'; NodesMatrix2(i,1) = _evstr_(resu(StartNodeLine + (DimCoordinates+2)*(i-1)+2));

i= [1 : NumberOfNodes]'.*.ones(1,DimCoordinates)';

j= ones(1,NumberOfNodes)'.*.[1 : DimCoordinates]';

k= StartNodeLine + (DimCoordinates+2)*(i-1)+3+j;

a= _evstr_(resu(k));

NodesMatrix2(i,j+1)= _evstr_(resu(k)); /// does not work/

///NodesMatrix2(i,j+1) = 1; // work(basic assignement)/

Duration2= toc()

*/EXPORT CONTROL :
/**Cet email ne contient pas de données techniques
This email does not contain technical data*



_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users






_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

 


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
amonmayr amonmayr
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Re: submatrix issue

Le 01/06/2018 à 12:46, Carrico, Paul a écrit :

Evstr(resu(k)) is a paste error - I’m reading an asci file J

Without using a loop, I would like to get the n th component of the vector resu(k) … k is no more no less than the index of specific lines I’m trying to get …

Through your answers I’m understanding that I’m thinking on a bad way


I think you can achieve what you want to do without a for loop.
But my feeling is that there is something wrong with the way you index your matrix NodesMatrix2(i,j+1) and your results resu(k).
When you index with "i" and "j+1" that are vectors of length N & M, you are basically indexing NxM elements of you matrix.
This seems to be the core of the issue here.
Maybe  indexing your matrix like a vector (ie NodesMatrix2(p) with p in [1:length(NodesMatrix2)]) would be better.

Antoine

Paul

 

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data

 

De : users [[hidden email]] De la part de antoine monmayrant
Envoyé : vendredi 1 juin 2018 11:55
À : [hidden email]
Objet : [EXTERNAL] Re: [Scilab-users] submatrix issue

 

Hello,

 

What do you wan to achieve exactly?
As Stéphane pointed out, the sizes are not the same.
When you assign something like:

A=B;

You have two different situations:

1) size(A)==size(B)
2) size(B)=[1,1]

In the first case, you assign each element of B to each element of A. In the latter case (which corresponds to your commented line), B is just a scalar that gets assigned to each element of A.

In the current situation, you are neither in case 1) nor in case 2).
As you have size(NodesMatrix2(i,j+1))=[300,300] and size(resu(k))=[300,1], you might want to replicate resu(k) 300 times and fill NodesMatrix2(i,j+1) with these 300 copies. If this what you want to do, here is the code:

NodesMatrix2(i,j+1)=resu(k)*ones(1,300);

 

By the way, why do you use "evstr(resu(k))" instead of "resu(k)"?

 

Antoine

 

Le 01/06/2018 à 11:45, Stéphane Mottelet a écrit :

It cannot work since

--> size(k)
 ans  =

   300.   1.


--> length(i)*length(j)
 ans  =

   90000.

i.e. NodesMatrix2(i,j+1) has 90000 elements and resu(k) has 300

S.

Le 01/06/2018 à 11:07, Carrico, Paul a écrit :


Dear all

I’ve a submatrix issue on the following example, and I do not remember (or understand) why : how can I do this ?

(the goal is to extract and to store within a matrix results from an Ascii file)

Thanks for any help

Paul

###############################################################

mode(0)

clearall

StartNodeLine= 1;

NumberOfNodes= 100;

DimCoordinates= 3;

resu= rand(1000,1);

tic();

NodesMatrix2= zeros(NumberOfNodes,DimCoordinates+1);

i= [1 : NumberOfNodes]'; NodesMatrix2(i,1) = _evstr_(resu(StartNodeLine + (DimCoordinates+2)*(i-1)+2));

i= [1 : NumberOfNodes]'.*.ones(1,DimCoordinates)';

j= ones(1,NumberOfNodes)'.*.[1 : DimCoordinates]';

k= StartNodeLine + (DimCoordinates+2)*(i-1)+3+j;

a= _evstr_(resu(k));

NodesMatrix2(i,j+1)= _evstr_(resu(k)); /// does not work/

///NodesMatrix2(i,j+1) = 1; // work(basic assignement)/

Duration2= toc()

*/EXPORT CONTROL :
/**Cet email ne contient pas de données techniques
This email does not contain technical data*



_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users






_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

 



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

 Antoine Monmayrant LAAS - CNRS
 7 avenue du Colonel Roche
 BP 54200
 31031 TOULOUSE Cedex 4
 FRANCE

 Tel:+33 5 61 33 64 59
 
 email : [hidden email]
 permanent email : [hidden email]

+++++++++++++++++++++++++++++++++++++++++++++++++++++++


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Re: submatrix issue

In reply to this post by Carrico, Paul

Paul,

 

Does your input ASCII file have N-lines with 3-values on each row:

X1 Y1 Z1

X2 Y2 Z2

or instead, does it have one value per row over Nx3 rows:

X1

Y1

Z1

X2

Y2

Z2

 

?

 

Regards,

Rafael

 


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
paul.carrico paul.carrico
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Re: submatrix issue

Hi Rafael,

Thanks for your interest,; I think I was wrong in my way of using 3 vectors at the same time,


To answer to your question, the structure is

N = Node number

2/3 = number of coordinates (2 for 2D and 3 for 3D obviously)

X

Y

(Z) if in 3D

[same structure for all the nodes]


Obviously I can use a loop, but vectorization is more efficient; I was thinking on a generic code that works for all the configuration .. the silmpliest way is to check since the beginning if we are in 3D or not, and to add anorther line if necessary:

- one vector to get the node number

- one for X and one for Y

if we are in 3D, then a new vector dealing to Z will be added


I'll have a look on it tomorrow :-)

Regards

Paul



Le 2018-06-03 15:56, Rafael Guerra a écrit :

Paul,

 

Does your input ASCII file have N-lines with 3-values on each row:

X1 Y1 Z1

X2 Y2 Z2

or instead, does it have one value per row over Nx3 rows:

X1

Y1

Z1

X2

Y2

Z2

 

?

 

Regards,

Rafael

 


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users