Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » New STEM4U package
New STEM4U package [message #53091] Tue, 25 February 2020 08:11 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

Science, technology, engineering, and mathematics involve a huge need of computing.

New Bazaar package STEM4U includes libraries focused to make life easier for those who want to make a better world through science and technology.

From now it begins with a few libraries. However more will be added in the future. You all are invited to support it being part of the authors' list.

One example of library included is Rational, an arbitrary precision rational number

We use computers for doing floating point calculations. However even using 64 bit types, lack of precision in calculations produce inaccuracies that go accumulating over time, thus increasing the error.

For example, lets compute y = 2/1 * 3/2 * 4/3 * ... If done n times, result has to be n.

However, the code implementing this will fail:
double val = 1;
for (double d = 1; d < 100; ++d) 
	val *= (d+1)/d;
Cout() << "double == 100: " << ((dval == 100) ? "true" : "false") << "\n";	// It returns false!?!?

Rational class solves this drawback implementing an arbitrary precision integer rational number.


Best regards
Iñaki
Re: New STEM4U package [message #54402 is a reply to message #53091] Sun, 12 July 2020 16:48 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Now STEM4U includes some financial functions:
- NetPresentValue()
- InternalRateOfReturn()
- PMT() (periodic payment for a loan)

Because successful engineering requires profitable investments Wink


Best regards
Iñaki

[Updated on: Sun, 12 July 2020 16:48]

Report message to a moderator

Re: New STEM4U package [message #54614 is a reply to message #54402] Thu, 20 August 2020 13:10 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Added Travelling Salesman algorithm. A demo is included in STEM4U_DemoTest.

The Traveling salesman problem (TSP) of a list of points calculates the shortest possible route that visits each point and returns to the origin.

This is a NP-hard problem that for medium sets could be impractical to be solved by an exact algorithm as brute force or linear programming. Because of that, for practical reasons, its resolution using heuristics and approximations is advised.

This implementation uses a Nearest neighbor algorithm to get an initial guess, and follows with a 2-opt algorithm.
template <typename T> T TSP(const Vector<Vector<T>>& matrix, Vector<int> &order)
Returns the total distance of a traveling salesman problem defined by a matrix of distances between nodes. All the elements of the diagonal of this matrix have to be zero, and the elements above the diagonal are considered. It also returns the most optimal order between the nodes.
order may include an initial guess of the right ordering. If not, order should be empty.
template <typename T> T TSP(const Vector<Point_<T>>& points, Vector<int> &order)
Returns the total distance of a traveling salesman problem defined by a list of euclidean coordinates of the points. It also returns the most optimal order between the nodes.
order may include an initial guess of the right ordering. If not, order should be empty.


Best regards
Iñaki
Re: New STEM4U package [message #54626 is a reply to message #54614] Sun, 23 August 2020 10:05 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
It is comforting that in these times of tribulation, someone knows how to find his way through the chaos.
Smile

index.php?t=getfile&id=6166&private=0


Best regards
Iñaki
Previous Topic: Building TheIDE with using CMake
Next Topic: plugin/assimp needs information about license
Goto Forum:
  


Current Time: Thu Mar 28 14:57:10 CET 2024

Total time taken to generate the page: 0.01663 seconds