Discussions related to Visual Prolog
User avatar
CalmoSoft
VIP Member
Posts: 73
Joined: 17 Oct 2006 5:49

Visual Prolog Speed

Unread post by CalmoSoft »

Hello Thomas et All,

I want to test the speed of Visual Prolog with two dimensional array (4000x4000 items)
I want to store to indices: array(i,j) = i*j
Can you post me a sample?

Greetings,
Gal Zsolt
(~ CalmoSoft ~)
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Visual Prolog Speed

Unread post by Harrison Pratt »

The "Game of Life" I posted in Visual Prolog Tips & Samples uses a 2D matrix.

http://discuss.visual-prolog.com/viewto ... 52674c8555
User avatar
CalmoSoft
VIP Member
Posts: 73
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft »

Hello Harrison,

Thanks for your useful help.
I look at it.

Greetings,
Gal Zsolt
(~ Calmosoft ~)
User avatar
CalmoSoft
VIP Member
Posts: 73
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft »

Hello Harrison et All,

I need your help.
I can not write the code.
Can you help me?

Greetings,
Gal Zsolt
(~ Calmosoft ~)
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Visual Prolog Speed

Unread post by Harrison Pratt »

Hi Gal,
I don't understand what you mean by "I can not write the code."
Were you able to look at the Game of Life (GOL) code?
Do you need a very simple example of using a 2D matrix?
User avatar
CalmoSoft
VIP Member
Posts: 73
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft »

Hello Harrison,

Yes, I need a very simple example of using a 2D matrix.

Greetings,
Gal Zsolt
(~ CalmoSoft~)
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Visual Prolog Speed

Unread post by Harrison Pratt »

Code: Select all

class predicates     demo : (). clauses     demo() :-         % create matrix         Rows = 100,         Cols = 100,         Matrix2D = array2M::newInitialize(Rows, Cols, 0),         % insert some values         Matrix2D:set(0, 0, 11),         Matrix2D:set(0, 1, 22),         % retrieve some values         ValueA = Matrix2D:get(0, 0),         ValueB = Matrix2D:get(0, 1),         % how big?         SizeX = Matrix2D:sizeX, % note that sizeX and sizeY are properties         SizeY = Matrix2D:sizeY,         % get all non-zero values; note that keys are stored as tuples(Row,Col)         VV =             [ V ||                 tuple(tuple(R, C), V) = Matrix2D:getAll_nd(),                 V <> 0             ].
Look at the collection class Help file for more info.

You should run this sample code in a simple console application and use the debugger to look at the data structures that are used.
User avatar
CalmoSoft
VIP Member
Posts: 73
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft »

Hello Harrison,

Thanks for your useful help.
I try to use them.

Greetings,
Gal Zsolt
(~ CalmoSoft ~)
User avatar
CalmoSoft
VIP Member
Posts: 73
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft »

Hello Harrison,

I hope I have the last question.
I want to use nested loops like this in Ring language:

array = newlist(4000,4000)
for n= 1 to 4000
for m= 1 to 4000
array[n][m] = n*m
next
next

Greetings,
Gal Zsolt
(~ CalmoSoft ~)
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Visual Prolog Speed

Unread post by Harrison Pratt »

You are infinitely more expert in Ring than I am.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Visual Prolog Speed

Unread post by Thomas Linder Puls »

array2M has 0-based indices. But if you ignore the 0 indices and just make the array one larger at each dimension then you can use 1-based indices.
The initialization code can look like this:

Code: Select all

        Size = 4000,         Array = array2M::new(Size + 1, Size + 1),         foreach N = std::fromTo(1, Size) do             foreach M = std::fromTo(1, Size) do                 Array:set(N, M, N * M)             end foreach         end foreach
If you like you can also combine the iteration into a single foreach:

Code: Select all

        Size = 4000,         Array = array2M::new(Size + 1, Size + 1),         foreach N = std::fromTo(1, Size) and M = std::fromTo(1, Size) do             Array:set(N, M, N * M)         end foreach
Regards Thomas Linder Puls
PDC
User avatar
CalmoSoft
VIP Member
Posts: 73
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft »

Hello Thomas,

Thanks for your useful help.
I will use them.

Greetings,
Gal Zsolt
(~ CalmoSoft ~)
Post Reply