Facebook Page
Twitter
RSS
+ Reply to Thread
Results 1 to 3 of 3
  1. MHB Apprentice

    Status
    Offline
    Join Date
    Mar 2014
    Posts
    2
    Thanks
    1 time
    Thanked
    1 time
    #1
    Hello, I'm not sure where to put this. I have spent the last week (14+ hour days) editing some code I have for selecting representative spectra for a remote sensing masters thesis I'm working on. The program is very-very slow, and I've been trying to speed it up as much as possible by NOT performing any conversions that are unnecessary. Which leads me to the problem I've been struggling with for the last 10 hours.

    I'll use a simple example:

    I have a vector (V1)
    [0,1,2,3]
    Which I reform into a matrix (M1)
    [0,1
    2,3]

    and perform matrix multiplication on itself, M1*M1
    which returns a matrix
    [2,3
    6,11]
    from which I take the sum total of all items in the matrix. So the desired answer is = 22

    Is there any way I can do this directly with the original vector (V1), without having to convert the original vector to a matrix? I know conversion is the easiest way - but not the most computationally efficient. And I'm nor so good at the maths.

  2. MHB Oldtimer
    MHB Site Helper
    MHB Math Scholar
    Opalg's Avatar
    Status
    Online
    Join Date
    Feb 2012
    Location
    Leeds, UK
    Posts
    2,180
    Thanks
    737 times
    Thanked
    6,045 times
    Thank/Post
    2.773
    Awards
    Graduate POTW Award (2016)  

MHB Analysis Award (2016)  

Graduate POTW Award (2015)  

Graduate POTW Award (Jul-Dec 2013)  

MHB Pre-University Math Award (Jul-Dec 2013)
    #2
    Quote Originally Posted by CyanBC View Post
    Hello, I'm not sure where to put this. I have spent the last week (14+ hour days) editing some code I have for selecting representative spectra for a remote sensing masters thesis I'm working on. The program is very-very slow, and I've been trying to speed it up as much as possible by NOT performing any conversions that are unnecessary. Which leads me to the problem I've been struggling with for the last 10 hours.

    I'll use a simple example:

    I have a vector (V1)
    [0,1,2,3]
    Which I reform into a matrix (M1)
    [0,1
    2,3]

    and perform matrix multiplication on itself, M1*M1
    which returns a matrix
    [2,3
    6,11]
    from which I take the sum total of all items in the matrix. So the desired answer is = 22

    Is there any way I can do this directly with the original vector (V1), without having to convert the original vector to a matrix? I know conversion is the easiest way - but not the most computationally efficient. And I'm nor so good at the maths.
    Hi Cyan and welcome to MHB! Suppose you do that same sequence of calculations algebraically, starting with a vector $[a,b,c,d].$ Then the matrix is $\begin{bmatrix} a&b \\c&d \end{bmatrix}.$ When you square it you get $\begin{bmatrix} a^2 + bc&b(a+d) \\c(a+d)&bc +d^2 \end{bmatrix}.$ The sum of the elements is $\Sigma = a^2 + 2bc + d^2 + (b+c)(a+d).$ With a little bit of algebraic manipulation you can write that as $\Sigma = (a+d)(a+b+c+d) - 2(ad-bc).$

    Presumably you can write a little subroutine to input $[a,b,c,d]$ and get out $\Sigma.$ That ought to be a bit faster than going via a matrix computation.

  3. MHB Apprentice

    Status
    Offline
    Join Date
    Mar 2014
    Posts
    2
    Thanks
    1 time
    Thanked
    1 time
    #3 Thread Author
    Thanks for illuminating that for me. Now that I see it, I think the original method may be more efficient.

Similar Threads

  1. Problem involving matrix multiplication and dot product in one proof!
    By gucci in forum Linear and Abstract Algebra
    Replies: 6
    Last Post: September 18th, 2013, 07:21
  2. Tensor multiplication 3 dimesnsions
    By dwsmith in forum Linear and Abstract Algebra
    Replies: 4
    Last Post: February 4th, 2013, 17:13
  3. series multiplication
    By Lisa91 in forum Analysis
    Replies: 3
    Last Post: January 16th, 2013, 06:56
  4. Property of Matrix Multiplication
    By Yankel in forum Linear and Abstract Algebra
    Replies: 3
    Last Post: December 6th, 2012, 14:55
  5. Matrix Multiplication
    By Yankel in forum Linear and Abstract Algebra
    Replies: 2
    Last Post: December 1st, 2012, 15:49

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Math Help Boards