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 7982297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:38:24+00:00 2026-06-04T10:38:24+00:00

I am pretty impressed by the C++ library Eigen which uses expression templates to

  • 0

I am pretty impressed by the C++ library Eigen which uses expression templates to gain enormous speedup in matrix/vector calculation.

I would like to clone this library in scala. As far as I know scalas type system is not powerful enough to do something like this, but it should be possible lightweight modular staging LMS. There seems to be several project out there (Delight, virtualization-lms,etc). Which would be the right to use for this kind of project in terms of reliability and performance?

Thanks

Edit: I just came across macros in scala 2.10. Maybe this is what I want to use here.

@om-nom-nom

The important part is explained in http://eigen.tuxfamily.org/dox/TopicInsideEigenExample.html

The example explains that a vector addition

u = v + w

does have good performance in (native) C++ since a temporary variable is created for the addition and the this variable is assigned to u as

for(int i = 0; i < size; i++) tmp[i] = v[i] + w[i];
for(int i = 0; i < size; i++) u[i] = tmp[i];

Eigen uses template metaprogramming (explained step by step in the link above) to reduce this at compile time to

for(int i = 0; i < size; i++) u[i] = v[i] + w[i];

which is obviously faster and does not need an extra variable.

  • 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-04T10:38:26+00:00Added an answer on June 4, 2026 at 10:38 am

    To correctly answer this question, you need to ask yourself extra questions:

    1. Are you really sure that C++ code with templates performs better than Scala code? Moderns benchmarks show Java is faster than C++ on matrix inversion. This is mainly due to an improvement in VMs, as well as in HW.

    2. How big are the business benefits you would obtain by having a faster matrix tool compared to the increased cost of dealing with unmanaged memory, dangling pointers, and increased errors and bug due to coding in C++ ?

    3. If the problem can be solved with satisfactory performances in Scala at small scale, and the differences become significant only at high scale, wouldn’t be reasonable to look at dividing the problem (matrix / vector multiplication) into different tasks which can be executed in parallel?

    Personal note:I had few emails discussions with Joshua Bloch, one of the most influential Java Developers ever and author of Effective Java, and he has pointed me towards an interesting presentation by Brian Goletz (author of Java Concurrency in Practice and very influential in the Java world as well): Not Your Father’s Von Neumann Machine: A Crash Course in
    Modern Hardware


    If you conclude that the benefit is there and this is significant, and that in the future your problem siz won’t grow so that you would not need to benefit of multi-core execution, you probably need to stay in C++. In the other case, have a look to Scala Macros, which are available since 2.10-M3.

    *Extra: avoiding an intermediate variable does not really make sense when using languages which runs on a top of VM such as Java or C#. In fact, as the article you pointed correctly described, there is a certain hazard in how the JVM translate java bytecode into assembler with the JIT. Many of the optimization you can run by hand are already applied by the JVM, and most of this reasoning is useless if you take the precaution of declaring methods and variables FINAL. *

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

Sidebar

Related Questions

I've seen this and I have to admit I'm pretty impressed: (source: blogspot.com )
I've recently started to use gRaphael for my graphing needs and am pretty impressed
I'm pretty new to jQuery... so far I'm impressed. But I encountered a situation
I have been playing with DynamicJasper lately, and have been pretty impressed. The only
I'm investigating the Argotic Syndication Framework , and I'm pretty impressed so far. However,
I'm currently looking into the spring-security framework - great stuff so far, pretty impressed.
I'm relatively new to both scala and jodatime, but have been pretty impressed with
Pretty new to C# (and I would describe myself as a beginner in programming,
I'm playing with the MVC Webgrid in a project, pretty impressed so far, but
Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out

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.