SBASIC & C++
-
- Super Gold Card
- Posts: 716
- Joined: Mon Nov 24, 2014 2:03 pm
Re: SBASIC & C++
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.
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.
Re: SBASIC & C++
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
This is also what the C compiler would be doing internally - It is just harder to tell it to
Tobias
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];
Tobias
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
-
- Super Gold Card
- Posts: 716
- Joined: Mon Nov 24, 2014 2:03 pm
Re: SBASIC & C++
Many thanks Tobias,
The TSP now runs with as many nodes as there is memory to allow for.
Your help has been indispensable...
Steve.
The TSP now runs with as many nodes as there is memory to allow for.
Your help has been indispensable...
Steve.
-
- Super Gold Card
- Posts: 716
- Joined: Mon Nov 24, 2014 2:03 pm
Re: SBASIC & C++
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.
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.
-
- Super Gold Card
- Posts: 716
- Joined: Mon Nov 24, 2014 2:03 pm
Re: SBASIC & C++
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.
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.
-
- Super Gold Card
- Posts: 716
- Joined: Mon Nov 24, 2014 2:03 pm
Re: SBASIC & C++
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.
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.
- NormanDunbar
- Forum Moderator
- Posts: 2276
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: SBASIC & C++
Well done Steve, and team.
Cheers,
Norm.
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
-
- Super Gold Card
- Posts: 716
- Joined: Mon Nov 24, 2014 2:03 pm
Re: SBASIC & C++
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.
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.
-
- Super Gold Card
- Posts: 716
- Joined: Mon Nov 24, 2014 2:03 pm
Re: SBASIC & C++
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).
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).