Fastest C or C++ math library

  • 6 Replies
  • 3809 Views
*

Kaeldric

  • Guest
Fastest C or C++ math library
« on: February 04, 2018, 02:12:48 pm »
Does anyone know the fastest C or C++ math library?  :-\
I'm writing a software based upon a lot of matrix calculations.

Thank you.  :)

*

keghn

  • Trusty Member
  • *********
  • Terminator
  • *
  • 824
Re: Fastest C or C++ math library
« Reply #1 on: February 04, 2018, 03:28:42 pm »
 There both about the same. But there are software libraries that are highly optimized for fast computing. Like openBAS. 

https://www.chpc.utah.edu/documentation/software/mathlibraries.php#fftw 

http://arma.sourceforge.net/ 

https://en.wikipedia.org/wiki/OpenBLAS 

https://github.com/BelaPlatform/Bela/wiki/Fast-math-functions 






*

8pla.net

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1307
  • TV News. Pub. UAL (PhD). Robitron Mod. LPC Judge.
    • 8pla.net
Re: Fastest C or C++ math library
« Reply #2 on: February 06, 2018, 01:05:40 am »
May I suggest inline Assembly Language is the fastest for mathematics in C language?
My Very Enormous Monster Just Stopped Using Nine

*

Kaeldric

  • Guest
Re: Fastest C or C++ math library
« Reply #3 on: February 10, 2018, 03:19:29 pm »
Thank you.
I tried BLAS and it seemed very fats to me. :)

May I suggest inline Assembly Language is the fastest for mathematics in C language?

Inline assembly code should be fine, but I don't have much experience. Are you sure it will be worth?

*

infurl

  • Administrator
  • ***********
  • Eve
  • *
  • 1372
  • Humans will disappoint you.
    • Home Page
Re: Fastest C or C++ math library
« Reply #4 on: February 10, 2018, 11:01:51 pm »
Inline assembly code should be fine, but I don't have much experience. Are you sure it will be worth?

I have decades of experience writing highly optimized code in assembly language and quite frankly nowadays, it is not worth it. C compilers (and numeric libraries) are so good that any tiny advantage that you might gain writing in assembler will be lost amongst the vast amount of time wasted just trying to write and debug it. The only time I would still consider using assembler is for an 8 bit microcontroller with very limited memory but that's probably not what you are using if speed is the most important factor.

*

8pla.net

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1307
  • TV News. Pub. UAL (PhD). Robitron Mod. LPC Judge.
    • 8pla.net
Re: Fastest C or C++ math library
« Reply #5 on: February 13, 2018, 12:42:28 am »
Friends,

The question was fastest (not worthiest) I thought.
But to me, inline asm makes C code look worthier.
( Though, infurl gave good advice to Kaeldric. )
My Very Enormous Monster Just Stopped Using Nine

*

Korrelan

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1454
  • Look into my eyes! WOAH!
    • YouTube
Re: Fastest C or C++ math library
« Reply #6 on: February 14, 2018, 05:08:02 pm »
If you’re using loads of trig functions, the usual generic method to increase speed is to pre-calculate as much as you can into lookup tables/ arrays.

Most compliers (Python, C++, Fortran, Java, etc) are obviously optimized for one dimensional arrays because multiplications aren’t required to calculate the array element address.

Code
‘// define arrays
Dim ASIn(360) as Single
Dim ACos(360) as Single

‘// pre-calculate arrays
Cs=360
de=(2* PI)/Cs
For d=1 to Cs
  ASin(d)=Sin(d*de)
  ACos(d)=Cos(d*de)
Next

‘// plot circle or rotate vector
For d=1 to Cs
  X=100+20*Asin(d)
  Y=100+20*ACos(d)
  PlotPoint x,y
Next

 :)
It thunk... therefore it is!...    /    Project Page    /    KorrTecx Website

 


Requirements for functional equivalence to conscious processing?
by DaltonG (General AI Discussion)
November 19, 2024, 11:56:05 am
Will LLMs ever learn what is ... is?
by HS (Future of AI)
November 10, 2024, 06:28:10 pm
Who's the AI?
by frankinstien (Future of AI)
November 04, 2024, 05:45:05 am
Project Acuitas
by WriterOfMinds (General Project Discussion)
October 27, 2024, 09:17:10 pm
Ai improving AI
by infurl (AI Programming)
October 19, 2024, 03:43:29 am
Atronach's Eye
by WriterOfMinds (Home Made Robots)
October 13, 2024, 09:52:42 pm
Running local AI models
by spydaz (AI Programming)
October 07, 2024, 09:00:53 am
Hi IM BAA---AAACK!!
by MagnusWootton (Home Made Robots)
September 16, 2024, 09:49:10 pm
LLaMA2 Meta's chatbot released
by spydaz (AI News )
August 24, 2024, 02:58:36 pm
ollama and llama3
by spydaz (AI News )
August 24, 2024, 02:55:13 pm
AI controlled F-16, for real!
by frankinstien (AI News )
June 15, 2024, 05:40:28 am
Open AI GPT-4o - audio, vision, text combined reasoning
by MikeB (AI News )
May 14, 2024, 05:46:48 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am

Users Online

334 Guests, 0 Users

Most Online Today: 491. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles