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 ~)
-
- VIP Member
- Posts: 458
- Joined: 5 Nov 2000 0:01
Re: Visual Prolog Speed
The "Game of Life" I posted in Visual Prolog Tips & Samples uses a 2D matrix.
http://discuss.visual-prolog.com/viewto ... 52674c8555
http://discuss.visual-prolog.com/viewto ... 52674c8555
-
- VIP Member
- Posts: 73
- Joined: 17 Oct 2006 5:49
Re: Visual Prolog Speed
Hello Harrison,
Thanks for your useful help.
I look at it.
Greetings,
Gal Zsolt
(~ Calmosoft ~)
Thanks for your useful help.
I look at it.
Greetings,
Gal Zsolt
(~ Calmosoft ~)
-
- VIP Member
- Posts: 73
- Joined: 17 Oct 2006 5:49
Re: Visual Prolog Speed
Hello Harrison et All,
I need your help.
I can not write the code.
Can you help me?
Greetings,
Gal Zsolt
(~ Calmosoft ~)
I need your help.
I can not write the code.
Can you help me?
Greetings,
Gal Zsolt
(~ Calmosoft ~)
-
- VIP Member
- Posts: 458
- Joined: 5 Nov 2000 0:01
Re: Visual Prolog Speed
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?
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?
-
- VIP Member
- Posts: 73
- Joined: 17 Oct 2006 5:49
Re: Visual Prolog Speed
Hello Harrison,
Yes, I need a very simple example of using a 2D matrix.
Greetings,
Gal Zsolt
(~ CalmoSoft~)
Yes, I need a very simple example of using a 2D matrix.
Greetings,
Gal Zsolt
(~ CalmoSoft~)
-
- VIP Member
- Posts: 458
- Joined: 5 Nov 2000 0:01
Re: Visual Prolog Speed
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
].
You should run this sample code in a simple console application and use the debugger to look at the data structures that are used.
-
- VIP Member
- Posts: 73
- Joined: 17 Oct 2006 5:49
Re: Visual Prolog Speed
Hello Harrison,
Thanks for your useful help.
I try to use them.
Greetings,
Gal Zsolt
(~ CalmoSoft ~)
Thanks for your useful help.
I try to use them.
Greetings,
Gal Zsolt
(~ CalmoSoft ~)
-
- VIP Member
- Posts: 73
- Joined: 17 Oct 2006 5:49
-
- VIP Member
- Posts: 458
- Joined: 5 Nov 2000 0:01
Re: Visual Prolog Speed
You are infinitely more expert in Ring than I am.
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
Re: Visual Prolog Speed
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:
If you like you can also combine the iteration into a single foreach:
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
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
PDC
-
- VIP Member
- Posts: 73
- Joined: 17 Oct 2006 5:49