The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 MATRIX multiply

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Robinou Posted - 10/14/2015 : 11:12:23 AM
Hi,

I would like to know if it's possible to multiply an MATRIX by another MATRIX in labtalk language? and if it's not possible how can i do?

Thanks a lot
6   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 10/20/2015 : 09:35:37 AM
Hi Robinou,

Your code works, but you have to create the 3rd sheet in your matrix book before running it (or, add a code to make it if absent).

--Hideo Fujii
OriginLab
Robinou Posted - 10/15/2015 : 11:23:29 AM
Effectively, my script is too slow and he makes bug.

I must do Origin C,

I make this function :
void matmut ()
{
MatrixPage mp("MATRIXG");
MatrixLayer ml1=mp.Layers(0);
MatrixLayer ml2=mp.Layers(1);
MatrixLayer ml3=mp.Layers(2);
MatrixObject mo1=ml1.MatrixObjects(0);
MatrixObject mo2=ml2.MatrixObjects(0);
MatrixObject mo3=ml3.MatrixObjects(0);

matrix<double> m1=mo1.GetDataObject();
matrix<double> m2=mo2.GetDataObject();
matrix<double>& result=mo3.GetDataObject();
result=m1*m2;
}

but i have an Unknow Error (See my image to see my Matrix

Do you have an idea?

Thanks a lot lot
Robinou Posted - 10/15/2015 : 06:50:28 AM
Thanks a lot Hideo
Hideo Fujii Posted - 10/14/2015 : 5:59:26 PM
Hi Robinou,

When you said multiplication of matrices, are you talking about the cell-to-cell operation; Or, in the sense of "dot product"?
If later, you can try the following script:
///////////////////////
range m1=[MBook1]1!1;
range m2=[MBook2]1!1;
nc1=m1.ncols; nr1=m1.nrows;
nc2=m2.ncols; nr2=m2.nrows;
if(nc1!=nr2) {
  type -a Two matrices are not compatible for dot product;
  return;
}
win -t m; //create output matrix
mbname$=%H;
range m3=[mbname$]1!1;
m3.nrows=nr1;
m3.ncols=nc2;
Loop(ii,1,nr1) {
  Loop(jj,1,nc2) {
    v=0;
    Loop(kk,1,nc1) {v+=(m1[ii,kk]*m2[kk,jj])}
    m3[ii,jj]=v;
  }
}
///////////////////////


For large matrices, this script may be too slow, and you might want to consider faster way such as in Origin C.

--Hideo Fujii
OriginLab
Robinou Posted - 10/14/2015 : 4:22:21 PM
Thanks for your quick reply!

It´s working when i have similar dimension between my matrix,

Unfortunaly, i would like to multiply a matrix with 6 columns and 6 rows by another Matrix with 6 rows and 20000 columns.

I use this for the moment :
Range [Mbook] mat1=MSheet1!1, mat2=MSheet2!1, mat3=MSheet3!1;
Mat3=mat2*mat1;

But it does'nt work.

Sorry for this question but i am a beginner in programming.
snowli Posted - 10/14/2015 : 2:24:31 PM
If you have 3 matrix books called MBook1, MBook2 and MBook3, u can run

MBook3=MBook1*MBook2

Thanks, Snow

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000