Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8333509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:03:31+00:00 2026-06-09T03:03:31+00:00

I am looking for a way to vectorize a combined matrix multiplication and element-wise

  • 0

I am looking for a way to vectorize a combined matrix multiplication and element-wise addition.

Let’s say I have a matrix function M_{ij}(x), and a vector function v_j(x), where {i,j} are matrix indices, and x is a position variable. I want to perform an element-wise matrix multiplication and find u(x) = M(x).v(x). A straightforward example is:

imax = 2; jmax = 3; xmax = 10;

M=rand(imax,jmax,xmax);
v=rand(jmax,xmax);
u=zeros(imax,xmax);

for i=1:imax
    for j=1:jmax
        u(i,:) = u(i,:) + squeeze(M(i,j,:))'.*v(j,:);
    end
end

Is there a vectorized way to speed up this operation? In my problem we will assume that imax,jmax are <5, and that xmax is large.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:03:33+00:00Added an answer on June 9, 2026 at 3:03 am

    Try

     u=squeeze(sum(bsxfun(@times,permute(M, [2 3 1]), v)))';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I'm looking for: way to have innate html 5 form validation using the
I'm looking at way to easily have objects similar to 'fixtures', but for the
looking a way to make a toggle on doubleclick, this is my code: $('#mydiv').toggle(function()
Is there any fast (and nice looking) way to remove an element from an
I was looking a way to sort struct using sort() function of STL:Algorithm library.
I'm looking for way to create list view as like in IOS with pinned
I'm looking a way to enable IP logging with log4net in ASP.NET. I found
I'm looking for way to write Javascript programs / scripts on desktop, not inside
I'm looking a way to build conditional assignments in bash: In Java it looks
I am using codeigniter and looking a way to enable directly editting of doc

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.