Page 1 of 2

General Maths Matrix Calculation (V1.0.1)

Posted: Fri Aug 05, 2011 12:28 am
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

Re: General Maths Matrix Calculation

Posted: Fri Aug 05, 2011 12:58 am
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

Re: General Maths Matrix Calculation

Posted: Fri Aug 05, 2011 2:13 am
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

Re: General Maths Matrix Calculation

Posted: Fri Aug 05, 2011 2:18 am
by IdeasVacuum
.....would be better to post it here:

http://www.purebasic.fr/english/viewtop ... 16&t=45701

Re: General Maths Matrix Calculation

Posted: Fri Aug 05, 2011 2:41 am
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

Re: General Maths Matrix Calculation

Posted: Fri Aug 05, 2011 12:44 pm
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.

Re: General Maths Matrix Calculation (V0.9.5)

Posted: Sun Aug 07, 2011 10:20 am
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

Re: General Maths Matrix Calculation (V0.9.7)

Posted: Wed Aug 17, 2011 2:40 pm
by Guimauve
Edit : See the download link in the first post for the most up to date version.

Best regards.
Guimauve

Re: General Maths Matrix Calculation (V0.9.7)

Posted: Wed Aug 17, 2011 2:42 pm
by Guimauve
Edit : See the download link in the first post for the most up to date version.

Best regards.
Guimauve

Re: General Maths Matrix Calculation (V0.9.7)

Posted: Wed Aug 17, 2011 2:42 pm
by Guimauve
Edit : See the download link in the first post for the most up to date version.

Best regards.
Guimauve

Re: General Maths Matrix Calculation (V0.9.7)

Posted: Wed Aug 17, 2011 2:43 pm
by Guimauve
Edit : See the download link in the first post for the most up to date version.

Best regards.
Guimauve

Re: General Maths Matrix Calculation (V0.9.8)

Posted: Wed Aug 17, 2011 9:44 pm
by IdeasVacuum
...lovely job Guimauve, thanks for sharing. I need a new mouse now, worn-out the scroll wheel! :mrgreen:

Re: General Maths Matrix Calculation (V0.9.8)

Posted: Wed Aug 17, 2011 9:48 pm
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 ;)

Re: General Maths Matrix Calculation (V1.0.1)

Posted: Sun Aug 28, 2011 9:48 pm
by Guimauve
A little update, see the first post.

Best regards.
Guimauve

Re: General Maths Matrix Calculation (V1.0.1)

Posted: Wed Jul 18, 2012 1:22 am
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)