SBASIC & C++

Anything QL Software or Programming Related.
stevepoole
Trump Card
Posts: 160
Joined: Mon Nov 24, 2014 2:03 pm

Re: SBASIC & C++

Postby stevepoole » Mon Feb 01, 2016 10:35 am

Thankyou Tobias,
Now all the malloc arrays compile and run OK.
Except that to transpose int distance[ARRAYSIZE][ARRAYSIZE] as you indicate, i get:
invalid types 'int[int]' for array subscript, when compiling with malloc...
There must be some special supplementary requirement to allocate 2D arrays in c++? (That is, how does the compiler know we want a square matrix?
Regards,
Steve.


User avatar
tofro
QL Wafer Drive
Posts: 1339
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: SBASIC & C++

Postby tofro » Mon Feb 01, 2016 12:20 pm

Steve,

dynamic multi-dimensional arrays (that is what you are trying to do) are hard to get by in C - To make things easier, it is nearly always best to allocate a single dimension and handle the multi-dimension on your own like

Code: Select all

// Allocate a two-dimensional array
d = (int*) malloc (FIRSTDIM * SECONDDIM * sizeof (int));
// access to element x,y
a = d [x * FIRSTDIM + y];


This is also what the C compiler would be doing internally - It is just harder to tell it to ;)

Tobias


stevepoole
Trump Card
Posts: 160
Joined: Mon Nov 24, 2014 2:03 pm

Re: SBASIC & C++

Postby stevepoole » Mon Feb 01, 2016 3:26 pm

Many thanks Tobias,
The TSP now runs with as many nodes as there is memory to allow for.
Your help has been indispensable...
Steve.


stevepoole
Trump Card
Posts: 160
Joined: Mon Nov 24, 2014 2:03 pm

Re: SBASIC & C++

Postby stevepoole » Fri Feb 12, 2016 2:27 pm

Hi,
I wrote a convex_hull routine in superbasic which uses little code, but whose running time is slugged as the number of nodes increases. (Printed as the TSP 'find_outers' in the Quanta magazine).
Does anyone have fast convex_hull code in basic or c++ that they would be prepared to share?
The TSP team are preparing the 'precise' TSP progam version for transcodage to c++.
The initial short TSP c++ version calculates 1000 nodes in one second, but is only 97% accurate. The latest version will also be much faster.
So far my attempts at fast convex-hull routines end up with excessively long code...and are buggy!
All suggestions will be appreciated...
Regards,
Steve.


stevepoole
Trump Card
Posts: 160
Joined: Mon Nov 24, 2014 2:03 pm

Re: SBASIC & C++

Postby stevepoole » Tue Jul 26, 2016 11:08 am

The Travelling Salesman Program in SuperBasic has now been successfully transcoded into an _exe file, using C68 and Cfix. The process was not automatic, as the basic needed tweaking to recopile.

But C68 uses some specific functions to emulate SB ones, such as SB_scale, etc.
Our team is now adapting the C68_code into Cee so it will run on PCs with Borland BGI graphics.

Has anyone already rewritten C68 SB_FuNctions in Cee? If so would you be prepared to divulge them?
The TSP program will be released when the SB to Cee adaption will have been finished. Our team is steadily recoding the SB_FuNctions, but if this has already been done it would save us time...

Such recoded SB_Functions are, of course, reuseable for any C68 to Cee program conversion!

Regards,
Steve Poole.


stevepoole
Trump Card
Posts: 160
Joined: Mon Nov 24, 2014 2:03 pm

Re: SBASIC & C++

Postby stevepoole » Fri Sep 02, 2016 11:55 pm

Finally the shrink team have transcoded the superbasic TSP code into C++. It runs around 200 times faster... which was the figure we have been looking for since the first posting on the subject. Now we can compare shrink to other heuristic programs running on pcS with Borland Graphics. And initial results look very good.
3 years of work have gone into the program, After a full testing cycle, we should know its full potential. More news will appear as soon as a windows version becomes finalised quite soon. Release dates have not yet been decided.
Thanks to all the parties whohave contributed advice and information on this forum.
Shrink shows that major research prottypes can be developed on QLs in basic, and later transcoded for the pc world.
QL Forever...
Steve Poole.


User avatar
NormanDunbar
Gold Card
Posts: 424
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: SBASIC & C++

Postby NormanDunbar » Sat Sep 03, 2016 10:23 pm

Well done Steve, and team.

Cheers,
Norm.


Why do they put lightning conductors on churches?
How come Tarzan never grew a beard?
stevepoole
Trump Card
Posts: 160
Joined: Mon Nov 24, 2014 2:03 pm

Re: SBASIC & C++

Postby stevepoole » Sat Sep 10, 2016 6:06 am

Hi,
Shrink C++ TSP has now been tested on a middle-range 64-bit laptop.
Formerly 200 times faster than superbasic on an old desktop machine, it , is now 400 times faster.
C++ is so very fast, but without superbasic, C68, CPort & Cfix, shrink would never have been written...
QL Forever!
Steve Poole.


stevepoole
Trump Card
Posts: 160
Joined: Mon Nov 24, 2014 2:03 pm

Re: SBASIC & C++

Postby stevepoole » Wed Jan 03, 2018 6:53 am

Hi,
The 'SHRINK' Travelling Salesman Program' was finalised some months ago, and an article describing its development appeared in the nov/dec 2017 Quanta Issue.

A short demonstration video can be seen at : https://1drv.ms/v/s!AiyNuhEqpD_Xlz1u3WMVeLJQrOgM

If anyone would like to see the code, please let me know, and we will consider posting it on the site...

The program is actually being assessed by major software houses, as it has broken new ground....

Regards,
Steve Poole,
(for the Shrink Team).



Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 6 guests