Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Special matrix multiplication
Replies: 18   Last Post: Mar 22, 2012 5:12 AM

 Messages: [ Previous | Next ]
 Milos Milenkovic Posts: 189 Registered: 4/4/09
Special matrix multiplication
Posted: Mar 15, 2012 12:10 PM

Dear all,
Recently I had a problem like this
suppose that we have two matrices, where each element has three values like follows:
>
> A=[(a1,b1,c1), (a2,b2,c2); (a3,b3,c3), (a4,b4,c4)]
> B=[(d1,e1,f1), (d2,e2,f2); (d3,e3,f3), (d4,e4,f4)]
>
> Now, I have to multiply these two matrices, and that is matrix C=A*B
>
> C=[ c11=(a1,b1,c1)*(d1,e1,f1)+(a2,b2,c2)*(d3,e3,f3), c12=(a1,b1,c1)*(d2,e2,f2)+(a2,b2,c2)*(d4,e4,f4); c21=(a3,b3,c3)*(d1,e1,f1)+(a4,b4,c4)*(d3,e3,f3), c22=(a3,b3,c3)*(d2,e2,f2)+(a4,b4,c4)*(d4,e4,f4)]
>
> where the most important here is the low for multiplying these three-value numbers is:
>
> (ai,bi,ci)*(di,ei,fi) = (bi*di+ei*(ai-bi), bi*ei , ei*ci+bi(fi-ei))

and we (Roger S.) solved it as follows:
A1 = A(:,1:3:n); A2 = A(:,2:3:n); A3 = A(:,3:3:n);
B1 = B(:,1:3:n); B2 = B(:,2:3:n); B3 = B(:,3:3:n);
C1 = A2*B1+(A1-A2)*B2; C2 = A2*B2; C3 = A3*B2+A2*(B3-B2);
C(:,3:3:end) = C3; C(:,2:3:end) = C2; C(:,1:3:end) = C1;

This is ok, but now I have to make this multiplication with respect to sign of these (ai,bi,ci) numbers, so if (ai,bi,ci) and (di,ei,fi) are >0 (they are >0, if bi and ei >0) then the upper solution is ok,
but when bi or ei is <0 than I have to apply next rule:
(ai,bi,ci)*(di,ei,fi) = (ei*ai+bi*(fi-ei), bi*ei , ei*ci+bi(di-ei))
Or, if (ai,bi,ci) and (di,ei,fi) are both <0 (they are <0, if bi and ei <0)
(ai,bi,ci)*(di,ei,fi) = (ei*ci+bi*(fi-ei), bi*ei , ei*ai+bi(di-ei))
So now, first I have to check if bi and ei are > or < and then to apply an appropriate rule for multiplying.
Any idea how to solve this?
Example:
A=[2 3 4 5 6 7; -3 -2 -1 3 4 5]
B=[0 2 4 -4 -3 -2; -6 -4 -3 4 7 8]
C=A*B
C=[c11=(2 3 4)*(0 2 4)+(5 6 7)*(-6 -4 -3) c12=(2 3 4)*(-4 -3 -2)+(5 6 7)*(4 7 8); c21=(-3 -2 -1)*(-4 -3 -2)+(3 4 5)*(4 7 8) c22=?.]
Best,
Milos
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://mathforum.org/kb/thread.jspa?threadID=2339934&messageID=7744964", "fetch_time": 1524751149000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2018-17/segments/1524125948214.37/warc/CC-MAIN-20180426125104-20180426145104-00409.warc.gz", "warc_record_offset": 193865572, "warc_record_length": 5839, "token_count": 945, "char_count": 2204, "score": 3.828125, "int_score": 4, "crawl": "CC-MAIN-2018-17", "snapshot_type": "latest", "language": "en", "language_score": 0.7443130612373352, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00042-of-00064.parquet"}