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

  • SEARCH
  • Home
  • 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 6649093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:43:59+00:00 2026-05-26T00:43:59+00:00

In my program — which uses the Eigen library — I need to operate

  • 0

In my program — which uses the Eigen library — I need to operate on 2D vectors. In my inner loop I have the following function:

static inline double eval(double x, double y, double xi, double yi)
{
    const double invlen2  = 1/(x*x + y*y);
    const double invlen4 = invlen2*invlen2;
    const double invlen6 = invlen4*invlen2;

    const double x2  = x*x,   y2  = y*y;
    const double x3  = x2*x,  y3  = y2*y;
    const double xi2 = xi*xi, yi2 = yi*yi;

    return x*invlen2 + invlen4*(x2*xi + 2*x*y*yi - xi*y2)
    + invlen6*(x3*xi2 + 3*x*y2*yi2 + 6*x2*y*xi*yi - 3*x*xi2*y2 - 2*y3*xi*yi - x3*yi2);
}

void f(Vector2d& out, const Vector2d& R, const Vector2d& r)
{
    out.x() = eval(R.x(), R.y(), r.x(), r.y());
    out.y() = eval(R.y(), R.x(), r.y(), r.x());
}

This expression, although messy, seems like a prime candidate for vectorisation as both the x() and y() computations follow identical paths. My question is how to do it with Eigen without needing to manually drop down to assembly.

  • 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-05-26T00:44:00+00:00Added an answer on May 26, 2026 at 12:44 am

    This answer has nothing to do with Eigen, but since you mentioned manually dropping down to assembly, I’ll add this.

    You don’t need to use assembly to vectorize code. There are compiler intrinsics that will let manually vectorize without assembly:

    http://software.intel.com/sites/products/documentation/studio/composer/en-us/2011/compiler_c/intref_cls/common/intref_overview.htm#intref_overview

    That said: It looks like Eigen already has internal support for vectorization, but it doesn’t appear to be applicable in your example. So I can see why you want to do it manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Most program languages have some kind of exception handling; some languages have return codes,
my program makes a random name that could have a-z this code makes a
I program simple control library that checks user input from text and format the
In Program.cs I have the below method that is checking and the Syncing 5
program reads the following data from a .txt file: f 3.40 f 4.00 m
My program is not doing a great job. In a loop, data from each
The program I am developing gets three times slower when I call the following
My program need to occupy some resources. I want it to release those resources
I program in PHP mostrly and Ruby sometimes I happen to be in need
I program mostly in PHP and have a site along with other samples in

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.