General Maths Matrix Calculation (V1.0.1)

Share your advanced PureBasic knowledge/code with the community.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

General Maths Matrix Calculation (V1.0.1)

Post by Guimauve »

Hello everyone,

Ok this is it ! A General Maths Matrix Calculation library in progress.

Edit : v0.9.9

Download link : http://pages.videotron.com/gsaumure/fil ... Matrix.zip

Edit 2 : V1.0.0

Ok I have updated the library to V1.0.0 and the html help files are on the way. My initial plan is to include advanced Splines and Surfaces to the Matrix library but they are to complicated but the more important thing I need to create some more little lib to program them. So they will be on a separate lib but still dependent to the Matrix Lib.

Edit 3 : V1.0.1

Ok this is the V1.0.1, I have added few commands, made few change and corrected a memory leak problem. But the most important thing, the html help files are ready for their first run (Please note that the English is my secondary language, so it's possible for you to find some mistakes, feel free to suggest correction !)

Have fun !

Best regards.
Guimauve
Last edited by Guimauve on Tue Jan 17, 2012 7:04 pm, edited 17 times in total.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: General Maths Matrix Calculation

Post by STARGÅTE »

Can it be that the code has some errors?

Example:
Procedure SetMatrixElement(*MatrixA.Matrix, P_Line.l, P_Row.l, P_Element.d)

If Line01 <= GetMatrixLine(*MatrixA) - 1 And Line02 <= GetMatrixLine(*MatrixA) - 1 And Line01 >= 0 And Line02 >= 0

Offset1D(Offset1D, GetMatrixLine(*MatrixA), P_Line, P_Row)
PokeD(ReachMatrixElement(*MatrixA, Offset1D), P_Element)

EndIf

EndProcedure
Otherwise well, but you can still optimize the speed.

It is good that you checked in SetMatrixElement () (if you've corrected it ^ ^) if there is a valid field.
But you do not have in your own functions.
There you can get a simplified "MySetMatrixElement" use, without check, which is then faster.

Btw:
Why you use a memory for matrix fields instead of an array like this:

Code: Select all

Structure Matrix
  LastX.i
  LastY.i
  Array Field.d(0)
EndStructure

Procedure NewMatrix(*Matrix.Matrix, Width.i, Height.i) ; 
	Dim *Matrix\Field(Height*Width-1)
	*Matrix\LastX = Width-1
	*Matrix\LastY = Height-1
EndProcedure
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: General Maths Matrix Calculation

Post by Guimauve »

STARGÅTE wrote:Can it be that the code has some errors?

Example:
Procedure SetMatrixElement(*MatrixA.Matrix, P_Line.l, P_Row.l, P_Element.d)

If Line01 <= GetMatrixLine(*MatrixA) - 1 And Line02 <= GetMatrixLine(*MatrixA) - 1 And Line01 >= 0 And Line02 >= 0

Offset1D(Offset1D, GetMatrixLine(*MatrixA), P_Line, P_Row)
PokeD(ReachMatrixElement(*MatrixA, Offset1D), P_Element)

EndIf

EndProcedure
Corrected ! See the first post.
STARGÅTE wrote: Btw:
Why you use a memory for matrix fields instead of an array like this:

Code: Select all

Structure Matrix
	LastX.i
	LastY.i
	Array Field.d(0)
EndStructure

Procedure NewMatrix(*Matrix.Matrix, Width.i, Height.i) ; 
		Dim *Matrix\Field(Height*Width-1)
		*Matrix\LastX = Width-1
		*Matrix\LastY = Height-1
EndProcedure
Because I prefer to manage the memory my self.

Best regards.
Guimauve
Last edited by Guimauve on Fri Aug 05, 2011 5:25 am, edited 1 time in total.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: General Maths Matrix Calculation

Post by IdeasVacuum »

.....would be better to post it here:

http://www.purebasic.fr/english/viewtop ... 16&t=45701
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: General Maths Matrix Calculation

Post by Guimauve »

IdeasVacuum wrote:.....would be better to post it here:

http://www.purebasic.fr/english/viewtop ... 16&t=45701
Yes this library can be used for games but to solve many maths problem not related to game as well.

Best regards.
Guimauve
User avatar
graph100
Enthusiast
Enthusiast
Posts: 115
Joined: Tue Aug 10, 2010 3:17 pm

Re: General Maths Matrix Calculation

Post by graph100 »

that's some pretty useful function here !
I need them to complete the one for vector I made. Math apps are always hardest to code than game ;'(
That could be of great help in a finite element code.
_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed ;))
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: General Maths Matrix Calculation (V0.9.5)

Post by Guimauve »

Hello,

Due to forum limitation (60 000 characters max) I have to split the library and the demonstration code in two files.
Just save the lib and Demo code in the same folder.

Edit : See the download link in the first post for the most up to date version.

Best regards
Guimauve
Last edited by Guimauve on Fri Aug 19, 2011 12:17 am, edited 1 time in total.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: General Maths Matrix Calculation (V0.9.7)

Post by Guimauve »

Edit : See the download link in the first post for the most up to date version.

Best regards.
Guimauve
Last edited by Guimauve on Fri Aug 19, 2011 12:22 am, edited 2 times in total.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: General Maths Matrix Calculation (V0.9.7)

Post by Guimauve »

Edit : See the download link in the first post for the most up to date version.

Best regards.
Guimauve
Last edited by Guimauve on Fri Aug 19, 2011 12:18 am, edited 2 times in total.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: General Maths Matrix Calculation (V0.9.7)

Post by Guimauve »

Edit : See the download link in the first post for the most up to date version.

Best regards.
Guimauve
Last edited by Guimauve on Fri Aug 19, 2011 12:22 am, edited 2 times in total.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: General Maths Matrix Calculation (V0.9.7)

Post by Guimauve »

Edit : See the download link in the first post for the most up to date version.

Best regards.
Guimauve
Last edited by Guimauve on Fri Aug 19, 2011 12:19 am, edited 1 time in total.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: General Maths Matrix Calculation (V0.9.8)

Post by IdeasVacuum »

...lovely job Guimauve, thanks for sharing. I need a new mouse now, worn-out the scroll wheel! :mrgreen:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
graph100
Enthusiast
Enthusiast
Posts: 115
Joined: Tue Aug 10, 2010 3:17 pm

Re: General Maths Matrix Calculation (V0.9.8)

Post by graph100 »

thanks again Guimauve ^^

@IdeasVacuum : you could use this : http://www.purebasic.fr/french/viewtopic.php?f=8&t=9608 to avoid breaking your mouse ;)
_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed ;))
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: General Maths Matrix Calculation (V1.0.1)

Post by Guimauve »

A little update, see the first post.

Best regards.
Guimauve
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: General Maths Matrix Calculation (V1.0.1)

Post by IdeasVacuum »

...almost a year later and I have just used the MMC Help for the first time!

Have to say that it is extremely well presented, fantastic job. 8)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply