Visual Prolog Speed

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

Visual Prolog Speed

Unread post by CalmoSoft » 1 Jun 2020 9:30

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 ~)
There are two types of programmers :
the one who already uses Ring
or Visual Prolog and the others
who are going to use them some time.

Harrison Pratt
VIP Member
Posts: 323
Joined: 5 Nov 2000 0:01

Re: Visual Prolog Speed

Unread post by Harrison Pratt » 1 Jun 2020 12:05

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: 63
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft » 1 Jun 2020 12:20

Hello Harrison,

Thanks for your useful help.
I look at it.

Greetings,
Gal Zsolt
(~ Calmosoft ~)
There are two types of programmers :
the one who already uses Ring
or Visual Prolog and the others
who are going to use them some time.

User avatar
CalmoSoft
VIP Member
Posts: 63
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft » 2 Jun 2020 6:20

Hello Harrison et All,

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

Greetings,
Gal Zsolt
(~ Calmosoft ~)
There are two types of programmers :
the one who already uses Ring
or Visual Prolog and the others
who are going to use them some time.

Harrison Pratt
VIP Member
Posts: 323
Joined: 5 Nov 2000 0:01

Re: Visual Prolog Speed

Unread post by Harrison Pratt » 2 Jun 2020 12:27

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: 63
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft » 2 Jun 2020 12:56

Hello Harrison,

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

Greetings,
Gal Zsolt
(~ CalmoSoft~)
There are two types of programmers :
the one who already uses Ring
or Visual Prolog and the others
who are going to use them some time.

Harrison Pratt
VIP Member
Posts: 323
Joined: 5 Nov 2000 0:01

Re: Visual Prolog Speed

Unread post by Harrison Pratt » 2 Jun 2020 14:10

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: 63
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft » 2 Jun 2020 17:34

Hello Harrison,

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

Greetings,
Gal Zsolt
(~ CalmoSoft ~)
There are two types of programmers :
the one who already uses Ring
or Visual Prolog and the others
who are going to use them some time.

User avatar
CalmoSoft
VIP Member
Posts: 63
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft » 2 Jun 2020 17:45

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 ~)
There are two types of programmers :
the one who already uses Ring
or Visual Prolog and the others
who are going to use them some time.

Harrison Pratt
VIP Member
Posts: 323
Joined: 5 Nov 2000 0:01

Re: Visual Prolog Speed

Unread post by Harrison Pratt » 3 Jun 2020 2:35

You are infinitely more expert in Ring than I am.

User avatar
Thomas Linder Puls
VIP Member
Posts: 1176
Joined: 28 Feb 2000 0:01

Re: Visual Prolog Speed

Unread post by Thomas Linder Puls » 3 Jun 2020 8:32

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: 63
Joined: 17 Oct 2006 5:49

Re: Visual Prolog Speed

Unread post by CalmoSoft » 3 Jun 2020 13:41

Hello Thomas,

Thanks for your useful help.
I will use them.

Greetings,
Gal Zsolt
(~ CalmoSoft ~)
There are two types of programmers :
the one who already uses Ring
or Visual Prolog and the others
who are going to use them some time.

Post Reply