j'ai besoin de travailler avec des coordonnées homogènes.
Existe-t-il une librairie, un module quelconque sous PB facilitant le calcul matriciel ?
Merci. Gilles

Code : Tout sélectionner
Dim maMatcice(3,3)
; Placer des valeur
; colonne 1 ligne 1
maMatcice(0,0) = 50
; colonne 1 ligne 2
maMatcice(0,1) = 30
; etc ...
; Lire une valeur
maVal = maMatcice(0,0) ;colonne 1 ligne 1
Code : Tout sélectionner
[url=https://fr.wikipedia.org/wiki/Coordonn%C3%A9es_homog%C3%A8nes]coordonnées homogènes[/url]
et pas
[url=https://fr.wikipedia.org/wiki/Coordonnées_homogènes]coordonnées homogènes[/url]
Cela ne veut rien dire. Le code date de 2006. Vous faites comment dans votre communauté dans de tels cas ?; Fichier : Code Prototype à ajuster au besoin.
c'est simple , tout ce qui est sur le forum est en principe libre d'utilisation ..selzig a écrit :b]Vous faites comment dans votre communauté dans de tels cas ?[/b]
Code : Tout sélectionner
Procedure Toto (par1,par2)
; by Zorro <------------------ ceci est un tag que l'auteur laisse dans sa procedure et qui ne devrai jamais etre effacé !! mais il y a les malotrus partout
***
***
EndProcedure
Code : Tout sélectionner
Global Dim mat1(2,2),Dim mat2(2,2),Dim res(2,2)
mat1(0,0) = 5
mat1(1,0) = 6
mat1(0,1) = 8
mat1(1,1) = 12
mat2(0,0) = 15
mat2(1,0) = -6
mat2(0,1) = 3
mat2(1,1) = 4
; mat1
; | 5 6 |
; | 8 12 |
; mat2
; |15 -6 |
; | 3 4 |
; Addition de mat1 et mat2
For c = 0 To 1 ; colonne
For r = 0 To 1 ;ligne
res(c,r) = mat1(c,r) + mat2(c,r)
Next
Next
Define text.s
; Affichage du résultat
For r = 0 To 1 ; colonne
text+" | "
For c = 0 To 1 ;ligne
text + " "+Str(res(c,r))
Next
text +" | "+ Chr(10); + " | "
Next
Debug text
Code : Tout sélectionner
Global Dim mat1(2,2),Dim mat2(2,2),Dim res(2,2)
mat1(0,0) = 5
mat1(1,0) = 6
mat1(0,1) = 8
mat1(1,1) = 12
mat2(0,0) = 15
mat2(1,0) = -6
mat2(0,1) = 3
mat2(1,1) = 4
; mat1
; | 5 6 |
; | 8 12 |
; mat2
; |15 -6 |
; | 3 4 |
; Multiplication de mat1 et mat2
For c = 0 To 1 ; colonne
For r = 0 To 1 ;ligne
res(c,r) = mat1(c,r) * mat2(r,c)
Next
Next
Define text.s
; Affichage du résultat
For r = 0 To 1 ; colonne
text+" | "
For c = 0 To 1 ;ligne
text + " "+Str(res(c,r))
Next
text +" | "+ Chr(10); + " | "
Next
Debug text
Code : Tout sélectionner
; Date : 04-08-2011
; Last Update : 28-08-2011
; PureBasic code : 4.60
; Plateform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Evolution History :
;
; V0.9.1
; Bug Correction
; Added : Private_SetMatrixElement(MatrixA, P_Line, P_Row, P_Element) [optimisation]
; Added : Private_GetMatrixElement(MatrixA, P_Line, P_Row) [optimisation]
;
; V 0.9.2
; Bug Correction
; Added : ReadMatrix(FileID.l, *MatrixA.Matrix)
; Added : WriteMatrix(FileID.l, *MatrixA.Matrix)
; Added : CalculateOffset1D(MaxA.l, IndexA.l, IndexB.l)
; Removed : Offset1D(Offset1D, MaxA, IndexA, IndexB)
;
; V0.9.3
; Added : LinearlySpacedVector(*MatrixA.Matrix, P_Min.d, P_Max.d, P_IncrementMax.l, P_Mode.b = 0)
; Added : LagrangePathFromWaypoints(*Waypoint.Matrix, *InterpolationValue.Matrix, *Path.Matrix)
; Added : EvaluateMatrixLineAsPolynom(*MatrixA.Matrix, LineID.l, P_u.d)
;
; V0.9.4
; Improvement : GaussJordanInverseMatrix(*Inverse.Matrix, *MatrixA.Matrix)
; Improvement : DeterminantMatrix(*MatrixA.Matrix)
;
; V0.9.5
; Improvement : LinearlySpacedVector(*MatrixA.Matrix, P_Min.d, P_Max.d, P_IncrementMax.l, P_Mode.b = 0)
; Improvement : ZeroMatrix(*MatrixA.Matrix, P_Line.l, P_Row.l)
; Improvement : OneMatrix(*MatrixA.Matrix, P_Line.l, P_Row.l)
; Improvement : PlusMatrix(*MatrixA.Matrix, *MatrixA.Matrix, *MatrixB.Matrix)
; Improvement : MinusMatrix(*MatrixR.Matrix, *MatrixA.Matrix, *MatrixB.Matrix)
; Added : ExtractMatrixDiagonal(*Diagonal.Matrix, *MatrixA.Matrix)
; Added : Matrix_To_String(*MatrixA.Matrix, P_Decimal.b = 3)
; Added : SetMatrixXMLNode(CurrentNode, *MatrixA.Matrix, P_Decimal.b = 6)
; Added : GetMatrixXMLNode(CurrentNode, *MatrixA.Matrix)
; Added : CreateMatrixXMLFile(FileID.l, FileName.s, *MatrixA.Matrix)
; Added : LoadMatrixXMLFile(FileID.l, FileName.s, *MatrixA.Matrix)
; Added : CatchMatrixXMLFile(FileID.l, *Buffer.i, BufferSize.l, *MatrixA.Matrix)
; Added : ReadPreferenceMatrix(Keyword.s, *MatrixA.Matrix, DefaultMatrix.s = "[0]")
; Added : WritePreferenceMatrix(Keyword.s, *MatrixA.Matrix, P_Decimal.b = 6)
; Added : AddMatrix(*MatrixR.Matrix, *MatrixA.Matrix)
; Added : SubstractMatrix(*MatrixR.Matrix, *MatrixA.Matrix)
;
; V0.9.6
; Improvement : GaussJordanInverseMatrix(*Inverse.Matrix, *MatrixA.Matrix)
; Improvement : DeterminantMatrix(*MatrixA.Matrix)
; Modified : CalulateOffset1D(RowMax.l, LineID.l, RowID.l)
; Added : DeCasteljauMatrix(Order.l, *D_Zero.Matrix, *D_One.Matrix)
;
; V0.9.7
; Modified : Matrix Structure (Line, Row and Size types)
; Modified : Matrix size Limited to : [65535 X 65535]
; Modified : CalulateOffset1D(RowMax.u, LineID.u, RowID.u)
; Modified : SetMatrixElement(*MatrixA.Matrix, P_Line.u, P_Row.u, P_Element.d)
; Modified : GetMatrixElement(*MatrixA.Matrix, P_Line.u, P_Row.u)
; Modified : CreateNewMatrix(*MatrixA.Matrix, P_Line.u, P_Row.u, CreatorCommand.s = "CreateNewMatrix()")
; Modified : ReadMatrix(FileID.l, *MatrixA.Matrix)
; Modified : WriteMatrix(FileID.l, *MatrixA.Matrix)
; Modified : IdentityMatrix(*MatrixA.Matrix, P_Size.u)
; Modified : ZeroMatrix(*MatrixA.Matrix, P_Line.u, P_Row.u)
; Modified : OneMatrix(*MatrixA.Matrix, P_Line.u, P_Row.u)
; Modified : LinearlySpacedVector(*MatrixA.Matrix, P_Min.d, P_Max.d, P_IncrementMax.u, P_Mode.b = 0)
; Modified : ExtractMatrixDiagonal(*Diagonal.Matrix, *MatrixA.Matrix)
; Modified : SwapMatrixLine(*MatrixA.Matrix, Line01.u, Line02.u)
; Modified : SwapMatrixRow(*MatrixA.Matrix, Row01.u, Row02.u)
; Modified : EvaluateMatrixLineAsPolynom(*MatrixA.Matrix, LineID.u, P_u.d)
; Modified : EvaluateMatrixRowAsPolynom(*MatrixA.Matrix, RowID.u, P_u.d)
; Modified : LagrangePolynomMatrix(P_PointCount.u, *Coefficient.Matrix, *CoefficientInverse.Matrix)
; Modified : DeCasteljauMatrix(Order.u, *D_Zero.Matrix, *D_One.Matrix)
; Modified : GetMatrixXMLNode(CurrentNode, *MatrixA.Matrix)
; Improvement : ProductMatrixByScalar(*MatrixR.Matrix, *MatrixA.Matrix, P_Scalar.d)
; Improvement : GaussJordanInverseMatrix(*Inverse.Matrix, *MatrixA.Matrix)
; Added : RandomMatrix(*MatrixA.Matrix, P_Line.u, P_Row.u, P_Min.d, P_Max.d, P_Resolution.l = 10000)
;
; V0.9.8
; Modified : EvaluatePolynomialMatrixLine(*MatrixA.Matrix, LineID.u, P_u.d)
; Modified : EvaluatePolynomialMatrixRow(*MatrixA.Matrix, RowID.u, P_u.d)
; Modified : EvaluatePolynomialMatrix(*Equations.Matrix, *U_Param.Matrix, *Result.Matrix)
; Modified : DerivatePolynomialMatrix(*Derivate.Matrix, *Equations.Matrix)
; Modified : IntegratePolynomialMatrix(*Integral.Matrix, *Equations.Matrix, *Cte.Matrix = #Null)
; Modified : LagrangePolynomialMatrix(P_PointCount.u, *Coefficient.Matrix, *CoefficientInverse.Matrix)
; Added : SaveMatrixToCSVFile(FileID.l, FileName.s, *MatrixA.Matrix, P_Decimal.b = 6)
; Added : TrefoilKnotWaypointMatrix(*InterpolationValue.Matrix, *Path.Matrix, P_LeafCount.l = 3, P_e.l = 1)
; Added : ExtractMatrixMinor(P_MinorLine.u, P_MinorRow.u, *Minor.Matrix, *MatrixA.Matrix)
; Added : TridiagonalMatrix(*MatrixA.Matrix, P_Size.u, P_DiagonalValue.d)
; Added : TridiagonalMatrixEx(*MatrixA.Matrix, *Diagonal.Matrix)
; Added : CatmullRomInverseCoefficient(*InverseCoeff.Matrix)
; Added : CatmullRomPathFromWaypoint(*Waypoint.Matrix, *InterpolationValue.Matrix, *Path.Matrix)
; Added : CatmullRomPathFusion(*Fusion.Matrix, *PathA.Matrix, *PathB.Matrix)
; Added : CatmullRomInsertWaypoint(*Waypoint.Matrix, *NewPoint.Matrix)
; Added : HermiteInverseCoefficient(*InverseCoeff.Matrix)
; Added : DebugPolynomialMatrix(*MatrixA.Matrix, P_Decimal.b = 3, P_Functions.s = "x(u),y(u),z(u)")
; Added : RotateXMatrix3D(*RotateX.Matrix, Theta.d)
; Added : RotateYMatrix3D(*RotateY.Matrix, Theta.d)
; Added : RotateZMatrix3D(*RotateZ.Matrix, Theta.d)
; Added : MirrorXMatrix3D(*MirrorX.Matrix)
; Added : MirrorYMatrix3D(*MirrorY.Matrix)
; Added : MirrorZMatrix3D(*MirrorZ.Matrix)
; Added : ScaleMatrix3D(*Scale.Matrix, Scale_x.d, Scale_y.d, Scale_z.d)
; Added : TranslationMatrix3D(*Translation.Matrix, Trans_x.d, Trans_y.d, Trans_z.d)
; Added : BezierCalculationMatrix(P_ControlPointCount.u, *MatrixN.Matrix)
; Added : BezierPathFromControlpoints(*Controlpoint.Matrix, *InterpolationValue.Matrix, *Path.Matrix)
;
; V0.9.9
; Modified : Matrix Structure (Size type)
; Modified : Matrix size Limited to : [16383 × 16383] due to problem with 32 bits processor
; Modified : CalulateOffset1D(RowMax.u, LineID.u, RowID.u)
; Modified : CreateNewMatrix(*MatrixA.Matrix, P_Line.u, P_Row.u, CreatorCommand.s = "CreateNewMatrix()")
; Modified : LinearlySpacedVector(*MatrixA.Matrix, P_Min.d, P_Max.d, P_IncrementMax.u, P_Mode.b = 0)
; Modified : PokeMatrixElement(MatrixA, P_Line, P_Row, P_Element)
; Modified : PeekMatrixElement(MatrixA, P_Line, P_Row)
; Modified : ReadMatrix(FileID.l, *MatrixA.Matrix)
; Modified : WriteMatrix(FileID.l, *MatrixA.Matrix)
; Modified : RotateXMatrix3D(*RotateX.Matrix, Theta.d)
; Modified : RotateYMatrix3D(*RotateY.Matrix, Theta.d)
; Modified : RotateZMatrix3D(*RotateZ.Matrix, Theta.d)
; Bug correction : ExtractMatrixDiagonal(*Diagonal.Matrix, *MatrixA.Matrix)
; Added : LoadMatrixFromCSVFile(FileID.l, FileName.s, *MatrixA.Matrix)
; Added : RotateMatrix2D(*Rotate.Matrix, Theta.d)
; Added : MirrorXMatrix2D(*MirrorX.Matrix)
; Added : MirrorYMatrix2D(*MirrorY.Matrix)
; Added : ScaleMatrix2D(*Scale.Matrix, Scale_x.d, Scale_y.d)
; Added : TranslationMatrix2D(*Translation.Matrix, Trans_x.d, Trans_y.d)
;
; V1.0.0
; Modified : RotateXMatrix3D(*RotateX.Matrix, Theta.d)
; Modified : RotateYMatrix3D(*RotateY.Matrix, Theta.d)
; Modified : RotateZMatrix3D(*RotateZ.Matrix, Theta.d)
; Added : LoadMatrixFromCSVFile(FileID.l, FileName.s, *MatrixA.Matrix)
; Added : RotateMatrix2D(*Rotate.Matrix, Theta.d)
; Added : MirrorXMatrix2D(*MirrorX.Matrix)
; Added : MirrorYMatrix2D(*MirrorY.Matrix)
; Added : ScaleMatrix2D(*Scale.Matrix, Scale_x.d, Scale_y.d)
; Added : TranslationMatrix2D(*Translation.Matrix, Trans_x.d, Trans_y.d)
;
; V1.0.1
; Memory Leak Correction
; Modified : NewUnicodeVector(ElementCount)
; Modified : DeleteUnicodeVector(StartPtr)
; Modified : ReachUnicodeVectorElement(StartPtr, Index)
; Modified : PokeUnicodeVectorElement(StartPtr, Index, Value)
; Modified : PeekUnicodeVectorElement(StartPtr, Index)
; Modified : ExtractMatrixMinor(P_MinorLine.u, P_MinorRow.u, *Minor.Matrix, *MatrixA.Matrix)
; Improvement : GaussJordanInverseMatrix(*Inverse.Matrix, *MatrixA.Matrix)
; Added : LUDecomposeMatrix(*MatrixA.Matrix, *L.Matrix, *U.matrix)
; Added : Private_GaussSolverSymbolicMatrix(*MatrixA.Matrix, ValidLineCount.u, *VarFlag.i, P_Decimal.b = 6)
; Added : GaussSolverMatrix(*EquationSystem.Matrix, *Constant.Matrix, *Solution.Matrix)
; Added : GaussSolverMatrixEx(*EquationSystem.Matrix, *Constant.Matrix, *Solution.Matrix, P_Decimal.b = 6)
; Added : #GAUSS_SOLVER_IMPOSSIBLE_SOLUTION, #GAUSS_SOLVER_SINGLE_SOLUTION, #GAUSS_SOLVER_INFINITE_SOLUTION
; Added : AugmentMatrixRow(*Augmented.Matrix, *MatrixA.Matrix, *MatrixB.Matrix)
; Added : AugmentMatrixLine(*Augmented.Matrix, *MatrixA.Matrix, *MatrixB.Matrix)
; Added : DebugAugmentedMatrixRow(*MatrixA.Matrix, P_FirstMatrixRowCount.u, P_Decimal.b = 3)
; Added : DebugAugmentedMatrixLine(*MatrixA.Matrix, P_FirstMatrixLineCount.u, P_Decimal.b = 3)
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; ValD_Patch_PB
Procedure.d ValD_Patch_PB(Number.s)
DotPosition = FindString(Number, ".", 0)
Integer_Part.d = Val(Number)
If DotPosition = 0
Decimal_Part.d = 0
Else
Decimal_Part_Str.s = Mid(Number, DotPosition + 1)
Max = Len(Decimal_Part_Str)
If Max > 18
Max = 18
Decimal_Part_Str = Left(Decimal_Part_Str, Max)
EndIf
Decimal_Part = Val(Decimal_Part_Str) / Pow(10, Max)
EndIf
ProcedureReturn Integer_Part + Decimal_Part
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Maths - BernsteinPolynomial
Procedure.d BernsteinPolynomial(P_m.l, P_i.l, P_u.d)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; The Bernstein Polynom function are based on Combinations
; calculation routine from Dr. Dri (French Forum)
If P_m >= 0 And P_i >= 0
Part.d = Pow(P_u, P_i) * Pow(1 - P_u, (P_m - P_i))
If P_m >= P_i
Combinations.d = 1.0
If P_i > P_m / 2
P_i = P_m - P_i
EndIf
While P_i > 0
Combinations * P_m / P_i
P_m - 1
P_i - 1
Wend
If Combinations - Round(Combinations, 0) > 0.5
Combinations + 1
EndIf
EndIf
EndIf
ProcedureReturn Round(Combinations, 0) * Part
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Maths - Minimum of two Values
Macro MinValue(P_Min, P_Value01, P_Value02)
P_Min = P_Value01
If P_Value02 < P_Min
P_Min = P_Value02
EndIf
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Maths - Random Min Max Real (Float or Double)
Macro RandomMinMaxReal(Min, Max, Resolution = 10000)
((Min) + ((Max) - (Min)) * Random(Resolution) / (Resolution))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; General - NewUnicodeVector
Macro NewUnicodeVector(ElementCount)
AllocateMemory((ElementCount) * SizeOf(Unicode))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; General - DeleteUnicodeVector
Macro DeleteUnicodeVector(StartPtr)
If StartPtr <> #Null
FreeMemory(StartPtr)
EndIf
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; General - ReachUnicodeVectorElement
Macro ReachUnicodeVectorElement(StartPtr, Index)
(StartPtr + (Index) * SizeOf(Unicode))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; General - PokeUnicodeVectorElement
Macro PokeUnicodeVectorElement(StartPtr, Index, Value)
PokeU(ReachUnicodeVectorElement(StartPtr, Index), Value)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; General - PeekUnicodeVectorElement
Macro PeekUnicodeVectorElement(StartPtr, Index)
PeekU(ReachUnicodeVectorElement(StartPtr, Index))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; General - UnicodeVectorSize
Macro UnicodeVectorSize(StartPtr)
(MemorySize(StartPtr) / SizeOf(Unicode))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; General - LastUnicodeVectorElement
Macro LastUnicodeVectorElement(StartPtr)
((UnicodeVectorSize(StartPtr)) - 1)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Constants declaration <<<<<
#GAUSS_SOLVER_IMPOSSIBLE_SOLUTION = 0
#GAUSS_SOLVER_SINGLE_SOLUTION = 1
#GAUSS_SOLVER_INFINITE_SOLUTION = 2
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Structure declaration <<<<<
Structure Matrix
Line.u
Row.u
Size.l
Elements.i
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The observators <<<<<
Macro GetMatrixLine(MatrixA)
MatrixA\Line
EndMacro
Macro GetMatrixRow(MatrixA)
MatrixA\Row
EndMacro
Macro GetMatrixSize(MatrixA)
MatrixA\Size
EndMacro
Macro GetMatrixElements(MatrixA)
MatrixA\Elements
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The mutators <<<<<
Macro SetMatrixLine(MatrixA, P_Line)
GetMatrixLine(MatrixA) = P_Line
EndMacro
Macro SetMatrixRow(MatrixA, P_Row)
GetMatrixRow(MatrixA) = P_Row
EndMacro
Macro SetMatrixSize(MatrixA, P_Size)
GetMatrixSize(MatrixA) = P_Size
EndMacro
Macro SetMatrixElements(MatrixA, P_Elements)
GetMatrixElements(MatrixA) = P_Elements
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Complentemary Macros for Datas <<<<<
Macro ReachMatrixElement(MatrixA, OffsetID)
(GetMatrixElements(MatrixA) + (OffsetID) * SizeOf(Double))
EndMacro
Macro AllocateMatrixElementsMemory(MatrixA)
SetMatrixElements(MatrixA, AllocateMemory(GetMatrixSize(MatrixA) * SizeOf(Double)))
EndMacro
Macro MemoryMatrixElementsSize(MatrixA)
MemorySize(GetMatrixElements(MatrixA))
EndMacro
Macro LastMatrixElements(MatrixA)
((MemorySize(GetMatrixElements(MatrixA)) / SizeOf(Double)) - 1)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Reset operator <<<<<
Macro ResetMatrix(MatrixA)
SetMatrixLine(MatrixA, 0)
SetMatrixRow(MatrixA, 0)
SetMatrixSize(MatrixA, 0)
If GetMatrixElements(MatrixA) <> #Null
FreeMemory(GetMatrixElements(MatrixA))
SetMatrixElements(MatrixA, 0)
EndIf
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Copy Operator : A = Source : B = Destination <<<<<
Macro CopyMatrix(MatrixA, MatrixB)
SetMatrixLine(MatrixB, GetMatrixLine(MatrixA))
SetMatrixRow(MatrixB, GetMatrixRow(MatrixA))
SetMatrixSize(MatrixB, GetMatrixSize(MatrixA))
If GetMatrixElements(MatrixB) <> #Null
FreeMemory(GetMatrixElements(MatrixB))
EndIf
AllocateMatrixElementsMemory(MatrixB)
If GetMatrixElements(MatrixB) <> #Null
CopyMemory(GetMatrixElements(MatrixA), GetMatrixElements(MatrixB), MemorySize(GetMatrixElements(MatrixA)))
EndIf
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Swap operator <<<<<
Macro SwapMatrix(MatrixA, MatrixB)
Swap GetMatrixLine(MatrixA), GetMatrixLine(MatrixB)
Swap GetMatrixRow(MatrixA), GetMatrixRow(MatrixB)
Swap GetMatrixSize(MatrixA), GetMatrixSize(MatrixB)
Swap GetMatrixElements(MatrixA), GetMatrixElements(MatrixB)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Offset 2D to 1D calculation <<<<<
Procedure.l CalulateOffset1D(RowMax.u, LineID.u, RowID.u)
If LineID = 0 And RowID = 0
Offset1D.l = 0
ElseIf RowID > 0
Offset1D = RowID + LineID * RowMax
ElseIf LineID > 0
Offset1D = LineID * RowMax
EndIf
ProcedureReturn Offset1D
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Poke Peek Matrix Element <<<<<
Macro PokeMatrixElement(MatrixA, P_Line, P_Row, P_Element)
PokeD(ReachMatrixElement(MatrixA, CalulateOffset1D(GetMatrixRow(MatrixA), P_Line, P_Row)), P_Element)
EndMacro
Macro PeekMatrixElement(MatrixA, P_Line, P_Row)
PeekD(ReachMatrixElement(MatrixA, CalulateOffset1D(GetMatrixRow(MatrixA), P_Line, P_Row)))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Matrix Element Mutator <<<<<
Procedure SetMatrixElement(*MatrixA.Matrix, P_Line.u, P_Row.u, P_Element.d)
If P_Line <= GetMatrixLine(*MatrixA) - 1 And P_Row <= GetMatrixRow(*MatrixA) - 1
PokeMatrixElement(*MatrixA, P_Line, P_Row, P_Element)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Matrix Element Observator <<<<<
Procedure.d GetMatrixElement(*MatrixA.Matrix, P_Line.u, P_Row.u)
If P_Line <= GetMatrixLine(*MatrixA) - 1 And P_Row <= GetMatrixRow(*MatrixA) - 1
P_Element.d = PeekMatrixElement(*MatrixA, P_Line, P_Row)
EndIf
ProcedureReturn P_Element
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The CreateNewMatrix Operator <<<<<
Procedure CreateNewMatrix(*MatrixA.Matrix, P_Line.u, P_Row.u, CreatorCommand.s = "CreateNewMatrix()")
If P_Line < 1
P_Line = 1
EndIf
If P_Line > 16383
P_Line = 16383
EndIf
If P_Row < 1
P_Row = 1
EndIf
If P_Row > 16383
P_Row = 16383
EndIf
If GetMatrixElements(*MatrixA) <> #Null
ResetMatrix(*MatrixA)
EndIf
SetMatrixLine(*MatrixA, P_Line)
SetMatrixRow(*MatrixA, P_Row)
SetMatrixSize(*MatrixA, GetMatrixLine(*MatrixA) * GetMatrixRow(*MatrixA))
AllocateMatrixElementsMemory(*MatrixA)
If GetMatrixElements(*MatrixA) = #Null
MessageRequester("Fatal Error", CreatorCommand + " - Impossible To Allocate Memory !")
End
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The IdentityMatrix Operator <<<<<
Procedure IdentityMatrix(*MatrixA.Matrix, P_Size.u)
CreateNewMatrix(*MatrixA, P_Size, P_Size, "IdentityMatrix()")
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
If LineID = RowID
PokeMatrixElement(*MatrixA, LineID, RowID, 1.0)
Else
PokeMatrixElement(*MatrixA, LineID, RowID, 0.0)
EndIf
Next
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The TridiagonalMatrix Operator <<<<<
Procedure TridiagonalMatrix(*MatrixA.Matrix, P_Size.u, P_DiagonalValue.d)
CreateNewMatrix(*MatrixA, P_Size, P_Size, "TridiagonalMatrix()")
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
If LineID = RowID
PokeMatrixElement(*MatrixA, LineID, RowID, P_DiagonalValue)
Else
PokeMatrixElement(*MatrixA, LineID, RowID, 0.0)
EndIf
Next
Next
For LineID = 0 To GetMatrixLine(*MatrixA) - 2
PokeMatrixElement(*MatrixA, LineID, LineID + 1, 1.0)
PokeMatrixElement(*MatrixA, LineID + 1, LineID, 1.0)
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The TridiagonalMatrixEx Operator <<<<<
Procedure TridiagonalMatrixEx(*MatrixA.Matrix, *Diagonal.Matrix)
CreateNewMatrix(*MatrixA, GetMatrixRow(*Diagonal), GetMatrixRow(*Diagonal), "TridiagonalMatrixEx()")
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
If LineID = RowID
PokeMatrixElement(*MatrixA, LineID, RowID, PeekMatrixElement(*Diagonal, 0, LineID))
Else
PokeMatrixElement(*MatrixA, LineID, RowID, 0.0)
EndIf
Next
Next
For LineID = 0 To GetMatrixLine(*MatrixA) - 2
PokeMatrixElement(*MatrixA, LineID, LineID + 1, 1.0)
PokeMatrixElement(*MatrixA, LineID + 1, LineID, 1.0)
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ZeroMatrix Operator <<<<<
Procedure ZeroMatrix(*MatrixA.Matrix, P_Line.u, P_Row.u)
CreateNewMatrix(*MatrixA, P_Line, P_Row, "ZeroMatrix()")
For OffsetID = 0 To GetMatrixSize(*MatrixA) - 1
PokeD(ReachMatrixElement(*MatrixA, OffsetID), 0.0)
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The OneMatrix Operator <<<<<
Procedure OneMatrix(*MatrixA.Matrix, P_Line.u, P_Row.u)
CreateNewMatrix(*MatrixA, P_Line, P_Row, "OneMatrix()")
For OffsetID = 0 To GetMatrixSize(*MatrixA) - 1
PokeD(ReachMatrixElement(*MatrixA, OffsetID), 1.0)
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Rotate 2D Operator <<<<<
Procedure RotateMatrix2D(*Rotate.Matrix, Theta.d)
Protected Cos.d, Sin.d
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
!FLD qword [p.v_Theta]
!FSINCOS
!FSTP qword [p.v_Cos]
!FSTP qword [p.v_Sin]
CompilerCase #PB_OS_Windows
!FLD qword [p.v_Theta]
!FSINCOS
!FSTP qword [p.v_Cos]
!FSTP qword [p.v_Sin]
CompilerCase #PB_OS_MacOS
Cos.d = Cos(Theta)
Sin.d = Sin(Theta)
CompilerEndSelect
IdentityMatrix(*Rotate, 3)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 1 <<<<<<
PokeMatrixElement(*Rotate, 0, 0, Cos)
PokeMatrixElement(*Rotate, 0, 1, -Sin)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 2 <<<<<<
PokeMatrixElement(*Rotate, 1, 0, Sin)
PokeMatrixElement(*Rotate, 1, 1, Cos)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< MirrorX 2D Operator <<<<<
Procedure MirrorXMatrix2D(*MirrorX.Matrix)
IdentityMatrix(*MirrorX, 3)
PokeMatrixElement(*MirrorX, 1, 1, -1.0)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< MirrorY 2D Operator <<<<<
Procedure MirrorYMatrix2D(*MirrorY.Matrix)
IdentityMatrix(*MirrorY, 3)
PokeMatrixElement(*MirrorY, 0, 0, -1.0)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Scale 3D operator <<<<<
Procedure ScaleMatrix2D(*Scale.Matrix, Scale_x.d, Scale_y.d)
IdentityMatrix(*Scale, 3)
PokeMatrixElement(*Scale, 0, 0, Abs(Scale_x))
PokeMatrixElement(*Scale, 1, 1, Abs(Scale_y))
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Translation 2D operator <<<<<
Procedure TranslationMatrix2D(*Translation.Matrix, Trans_x.d, Trans_y.d)
IdentityMatrix(*Translation, 3)
PokeMatrixElement(*Translation, 0, 3, Trans_x)
PokeMatrixElement(*Translation, 1, 3, Trans_y)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< RotateX 3D Operator <<<<<
Procedure RotateXMatrix3D(*RotateX.Matrix, Theta.d)
Protected Cos.d, Sin.d
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
!FLD qword [p.v_Theta]
!FSINCOS
!FSTP qword [p.v_Cos]
!FSTP qword [p.v_Sin]
CompilerCase #PB_OS_Windows
!FLD qword [p.v_Theta]
!FSINCOS
!FSTP qword [p.v_Cos]
!FSTP qword [p.v_Sin]
CompilerCase #PB_OS_MacOS
Cos.d = Cos(Theta)
Sin.d = Sin(Theta)
CompilerEndSelect
IdentityMatrix(*RotateX, 4)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 2 <<<<<<
PokeMatrixElement(*RotateX, 1, 1, Cos)
PokeMatrixElement(*RotateX, 1, 2, -Sin)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 3 <<<<<<
PokeMatrixElement(*RotateX, 2, 1, Sin)
PokeMatrixElement(*RotateX, 2, 2, Cos)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< RotateY 3D Operator <<<<<
Procedure RotateYMatrix3D(*RotateY.Matrix, Theta.d)
Protected Cos.d, Sin.d
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
!FLD qword [p.v_Theta]
!FSINCOS
!FSTP qword [p.v_Cos]
!FSTP qword [p.v_Sin]
CompilerCase #PB_OS_Windows
!FLD qword [p.v_Theta]
!FSINCOS
!FSTP qword [p.v_Cos]
!FSTP qword [p.v_Sin]
CompilerCase #PB_OS_MacOS
Cos.d = Cos(Theta)
Sin.d = Sin(Theta)
CompilerEndSelect
IdentityMatrix(*RotateY, 4)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 1 <<<<<<
PokeMatrixElement(*RotateY, 0, 0, Cos)
PokeMatrixElement(*RotateY, 0, 2, Sin)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 3 <<<<<<
PokeMatrixElement(*RotateY, 2, 0, -Sin)
PokeMatrixElement(*RotateY, 2, 2, Cos)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< RotateZ 3D Operator <<<<<
Procedure RotateZMatrix3D(*RotateZ.Matrix, Theta.d)
Protected Cos.d, Sin.d
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
!FLD qword [p.v_Theta]
!FSINCOS
!FSTP qword [p.v_Cos]
!FSTP qword [p.v_Sin]
CompilerCase #PB_OS_Windows
!FLD qword [p.v_Theta]
!FSINCOS
!FSTP qword [p.v_Cos]
!FSTP qword [p.v_Sin]
CompilerCase #PB_OS_MacOS
Cos.d = Cos(Theta)
Sin.d = Sin(Theta)
CompilerEndSelect
IdentityMatrix(*RotateZ, 4)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 1 <<<<<<
PokeMatrixElement(*RotateZ, 0, 0, Cos)
PokeMatrixElement(*RotateZ, 0, 1, -Sin)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 2 <<<<<<
PokeMatrixElement(*RotateZ, 1, 0, Sin)
PokeMatrixElement(*RotateZ, 1, 1, Cos)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< MirrorX 3D Operator (Plane YZ) <<<<<
Procedure MirrorXMatrix3D(*MirrorX.Matrix)
IdentityMatrix(*MirrorX, 4)
PokeMatrixElement(*MirrorX, 0, 0, -1.0)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< MirrorY 3D Operator (Plane XZ) <<<<<
Procedure MirrorYMatrix3D(*MirrorY.Matrix)
IdentityMatrix(*MirrorY, 4)
PokeMatrixElement(*MirrorY, 1, 1, -1.0)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< MirrorZ 3D Operator (Plane XY) <<<<<
Procedure MirrorZMatrix3D(*MirrorZ.Matrix)
IdentityMatrix(*MirrorZ, 4)
PokeMatrixElement(*MirrorZ, 2, 2, -1.0)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Scale 3D operator <<<<<
Procedure ScaleMatrix3D(*Scale.Matrix, Scale_x.d, Scale_y.d, Scale_z.d)
IdentityMatrix(*Scale, 4)
PokeMatrixElement(*Scale, 0, 0, Abs(Scale_x))
PokeMatrixElement(*Scale, 1, 1, Abs(Scale_y))
PokeMatrixElement(*Scale, 2, 2, Abs(Scale_z))
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Translation 3D operator <<<<<
Procedure TranslationMatrix3D(*Translation.Matrix, Trans_x.d, Trans_y.d, Trans_z.d)
IdentityMatrix(*Translation, 4)
PokeMatrixElement(*Translation, 0, 3, Trans_x)
PokeMatrixElement(*Translation, 1, 3, Trans_y)
PokeMatrixElement(*Translation, 2, 3, Trans_z)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The RandomMatrix Operator <<<<<
Procedure RandomMatrix(*MatrixA.Matrix, P_Line.u, P_Row.u, P_Min.d, P_Max.d, P_Resolution.l = 10000)
CreateNewMatrix(*MatrixA, P_Line, P_Row, "RandomMatrix()")
For OffsetID = 0 To GetMatrixSize(*MatrixA) - 1
PokeD(ReachMatrixElement(*MatrixA, OffsetID), RandomMinMaxReal(P_Min, P_Max, P_Resolution))
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The LinearlySpacedVector Operator <<<<<
Procedure LinearlySpacedVector(*MatrixA.Matrix, P_Min.d, P_Max.d, P_IncrementMax.u, P_Mode.b = 0) ; P_Mode = 0 --> Row Vector : P_Mode = 1 --> Line Vector
If P_IncrementMax >= 16383
P_IncrementMax = 16382
EndIf
Select P_Mode
Case 1
CreateNewMatrix(*MatrixA, 1, P_IncrementMax + 1, "LinearSpacedVector()")
For IncrementID = 0 To P_IncrementMax
PokeMatrixElement(*MatrixA, 0, IncrementID, (P_Min + (P_Max - P_Min) * (IncrementID / P_IncrementMax)))
Next
Default ; Row Vector is the default mode
CreateNewMatrix(*MatrixA, P_IncrementMax + 1, 1, "LinearSpacedVector()")
For IncrementID = 0 To P_IncrementMax
PokeMatrixElement(*MatrixA, IncrementID, 0, (P_Min + (P_Max - P_Min) * (IncrementID / P_IncrementMax)))
Next
EndSelect
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ExtractMatrixLine Operator <<<<<
Procedure ExtractMatrixLine(LineID.u, *Line.Matrix, *MatrixA.Matrix)
If LineID -1 >= 0
ZeroMatrix(*Line, 1, GetMatrixRow(*MatrixA))
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
PokeMatrixElement(*Line, 0, RowID, PeekMatrixElement(*MatrixA, LineID-1, RowID))
Next
EndIf
EndProcedure
Code : Tout sélectionner
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ReplaceMatrixLine Operator <<<<<
Procedure ReplaceMatrixLine(LineID.u, *Line.Matrix, *MatrixA.Matrix)
If LineID - 1 >= 0 And GetMatrixRow(*MatrixA) = GetMatrixRow(*Line)
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
PokeMatrixElement(*MatrixA, LineID-1, RowID, PeekMatrixElement(*Line, 0, RowID))
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ExtractMatrixRow Operator <<<<<
Procedure ExtractMatrixRow(RowID.u, *Row.Matrix, *MatrixA.Matrix)
If RowID -1 >= 0
ZeroMatrix(*Row, GetMatrixLine(*MatrixA), 1)
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
PokeMatrixElement(*Row, LineID, 0, PeekMatrixElement(*MatrixA, LineID, RowID - 1))
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ReplaceMatrixRow Operator <<<<<
Procedure ReplaceMatrixRow(RowID.u, *Row.Matrix, *MatrixA.Matrix)
If RowID -1 >= 0 And GetMatrixLine(*MatrixA) = GetMatrixLine(*Row)
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
PokeMatrixElement(*MatrixA, LineID, RowID - 1, PeekMatrixElement(*Row, LineID, 0))
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ExtractMatrixDiagonal Operator <<<<<
Procedure ExtractMatrixDiagonal(*Diagonal.Matrix, *MatrixA.Matrix)
MinValue(Min.u, GetMatrixLine(*MatrixA), GetMatrixRow(*MatrixA))
ZeroMatrix(*Diagonal, Min, 1)
For PivotID = 0 To Min - 1
PokeMatrixElement(*Diagonal, PivotID, 0, PeekMatrixElement(*MatrixA, PivotID, PivotID))
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ExtractMatrixMinor Operator <<<<<
Procedure ExtractMatrixMinor(P_MinorLine.u, P_MinorRow.u, *Minor.Matrix, *MatrixA.Matrix)
If GetMatrixLine(*MatrixA) = GetMatrixRow(*MatrixA) And (P_MinorLine - 1) <= GetMatrixLine(*MatrixA) And (P_MinorRow - 1) <= GetMatrixRow(*MatrixA) And (P_MinorLine - 1) >= 0 And (P_MinorRow - 1) >= 0
CreateNewMatrix(*Minor, GetMatrixLine(*MatrixA) - 1, GetMatrixRow(*MatrixA) - 1)
ValidLine = NewUnicodeVector(GetMatrixLine(*Minor))
ValidRow = NewUnicodeVector(GetMatrixRow(*Minor))
For Index = 0 To GetMatrixLine(*MatrixA) - 1
If Index <> (P_MinorLine - 1)
PokeUnicodeVectorElement(ValidLine, LineID, Index)
LineID + 1
EndIf
If Index <> (P_MinorRow - 1)
PokeUnicodeVectorElement(ValidRow, RowID, Index)
RowID + 1
EndIf
Next
For MinorLine = 0 To GetMatrixLine(*Minor) - 1
For MinorRow = 0 To GetMatrixRow(*Minor) - 1
PokeMatrixElement(*Minor, MinorLine, MinorRow, PeekMatrixElement(*MatrixA, PeekUnicodeVectorElement(ValidLine, MinorLine), PeekUnicodeVectorElement(ValidRow, MinorRow)))
Next
Next
DeleteUnicodeVector(ValidLine)
DeleteUnicodeVector(ValidRow)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The AugmentMatrixRow Operator <<<<<
Procedure AugmentMatrixRow(*Augmented.Matrix, *MatrixA.Matrix, *MatrixB.Matrix)
If GetMatrixLine(*MatrixA) = GetMatrixLine(*MatrixB)
ZeroMatrix(*Augmented, GetMatrixLine(*MatrixA), GetMatrixRow(*MatrixA) + GetMatrixRow(*MatrixB))
For LineID = 0 To GetMatrixLine(*Augmented) - 1
For RowID = 0 To GetMatrixRow(*Augmented) - 1
If RowID < GetMatrixRow(*MatrixA)
PokeMatrixElement(*Augmented, LineID, RowID, PeekMatrixElement(*MatrixA, LineID, RowID))
Else
PokeMatrixElement(*Augmented, LineID, RowID, PeekMatrixElement(*MatrixB, LineID, RowID2))
RowID2 + 1
EndIf
Next
RowID2 = 0
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The AugmentMatrixLine Operator <<<<<
Procedure AugmentMatrixLine(*Augmented.Matrix, *MatrixA.Matrix, *MatrixB.Matrix)
If GetMatrixRow(*MatrixA) = GetMatrixRow(*MatrixB)
ZeroMatrix(*Augmented, GetMatrixLine(*MatrixA) + GetMatrixLine(*MatrixB), GetMatrixRow(*MatrixA))
For RowID = 0 To GetMatrixRow(*Augmented) - 1
For LineID = 0 To GetMatrixLine(*Augmented) - 1
If LineID < GetMatrixRow(*MatrixA)
PokeMatrixElement(*Augmented, LineID, RowID, PeekMatrixElement(*MatrixA, LineID, RowID))
Else
PokeMatrixElement(*Augmented, LineID, RowID, PeekMatrixElement(*MatrixB, LineID2, RowID))
LineID2 + 1
EndIf
Next
LineID2 = 0
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The String_To_Matrix Operator <<<<<
Procedure String_To_Matrix(*MatrixA.Matrix, P_String.s)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; This operator must receive the Matrix from preformated
; string. Inside the string, the coma "," separate row
; element then the semicolon ";" separate line.
;
; Example of 5 by 2 matrix :
;
; P_String = "[1.0, 2.0; 4.0, 5.0; 3.0, 3.0; 5.0, 1.0; 7.0, 2.0]"
;
; [MatrixA] = [1.000, 2.000]
; [4.000, 5.000]
; [3.000, 3.000]
; [5.000, 1.000]
; [7.000, 2.000]
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
String.s = RemoveString(RemoveString(P_String, "["), "]")
LineCount = CountString(String, ";")
RowCount = CountString(StringField(String, 1, ";"), ",")
CreateNewMatrix(*MatrixA, LineCount + 1, RowCount + 1, "String_To_Matrix()")
For LineID = 0 To LineCount
For RowID = 0 To RowCount
PokeMatrixElement(*MatrixA, LineID, RowID, ValD_Patch_PB(StringField(StringField(String, LineID + 1, ";"), RowID + 1, ",")))
Next
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The String_To_Matrix Operator <<<<<
Procedure.s Matrix_To_String(*MatrixA.Matrix, P_Decimal.b = 3)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; This operator generate a matrix formated string
;
; Example of 5 by 2 matrix :
;
; [MatrixA] = [1.000, 2.000]
; [4.000, 5.000]
; [3.000, 3.000]
; [5.000, 1.000]
; [7.000, 2.000]
;
; P_String = "[1.0, 2.0; 4.0, 5.0; 3.0, 3.0; 5.0, 1.0; 7.0, 2.0]"
;
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
FormatedMatrix.s = FormatedMatrix + StrD(PeekMatrixElement(*MatrixA, LineID, RowID), P_Decimal)
If RowID < GetMatrixRow(*MatrixA) - 1
FormatedMatrix + ", "
EndIf
Next
If LineID < GetMatrixLine(*MatrixA) - 1
FormatedMatrix + "; "
EndIf
Next
ProcedureReturn "[" + FormatedMatrix + "]"
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The AddMatrix Operator <<<<<
Procedure AddMatrix(*MatrixR.Matrix, *MatrixA.Matrix)
If GetMatrixElements(*MatrixR) = #Null Or GetMatrixLine(*MatrixA) <> GetMatrixLine(*MatrixR) Or GetMatrixRow(*MatrixA) <> GetMatrixRow(*MatrixR)
ResetMatrix(*MatrixR)
CreateNewMatrix(*MatrixR, GetMatrixLine(*MatrixA), GetMatrixRow(*MatrixA), "AddMatrix()")
EndIf
If GetMatrixLine(*MatrixA) = GetMatrixLine(*MatrixR) And GetMatrixRow(*MatrixA) = GetMatrixRow(*MatrixR)
For OffsetID = 0 To GetMatrixSize(*MatrixA) - 1
PokeD(ReachMatrixElement(*MatrixR, OffsetID), PeekD(ReachMatrixElement(*MatrixR, OffsetID)) + PeekD(ReachMatrixElement(*MatrixA, OffsetID)))
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The PlusMatrix Operator <<<<<
Procedure PlusMatrix(*MatrixR.Matrix, *MatrixA.Matrix, *MatrixB.Matrix)
If *MatrixR <> *MatrixA And *MatrixR <> *MatrixB
AddMatrix(*MatrixR, *MatrixA)
AddMatrix(*MatrixR, *MatrixB)
ElseIf *MatrixR = *MatrixA
AddMatrix(*MatrixR, *MatrixB)
ElseIf *MatrixR = *MatrixB
AddMatrix(*MatrixR, *MatrixA)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The SubstractMatrix Operator <<<<<
Procedure SubstractMatrix(*MatrixR.Matrix, *MatrixA.Matrix)
If GetMatrixElements(*MatrixR) = #Null Or GetMatrixLine(*MatrixA) <> GetMatrixLine(*MatrixR) Or GetMatrixRow(*MatrixA) <> GetMatrixRow(*MatrixR)
ResetMatrix(*MatrixR)
CreateNewMatrix(*MatrixR, GetMatrixLine(*MatrixA), GetMatrixRow(*MatrixA), "SubstractMatrix()")
EndIf
If GetMatrixLine(*MatrixA) = GetMatrixLine(*MatrixR) And GetMatrixRow(*MatrixA) = GetMatrixRow(*MatrixR)
For OffsetID = 0 To GetMatrixSize(*MatrixA) - 1
PokeD(ReachMatrixElement(*MatrixR, OffsetID), PeekD(ReachMatrixElement(*MatrixR, OffsetID)) - PeekD(ReachMatrixElement(*MatrixA, OffsetID)))
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The MinusMatrix Operator <<<<<
Procedure MinusMatrix(*MatrixR.Matrix, *MatrixA.Matrix, *MatrixB.Matrix)
If *MatrixR <> *MatrixA And *MatrixR <> *MatrixB
SubstractMatrix(*MatrixR, *MatrixA)
SubstractMatrix(*MatrixR, *MatrixB)
ElseIf *MatrixR = *MatrixA
SubstractMatrix(*MatrixR, *MatrixB)
ElseIf *MatrixR = *MatrixB
SubstractMatrix(*MatrixR, *MatrixA)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ProductMatrix Operator <<<<<
Procedure ProductMatrix(*MatrixR.Matrix, *MatrixA.Matrix, *MatrixB.Matrix)
If GetMatrixRow(*MatrixA) = GetMatrixLine(*MatrixB)
ResetMatrix(*MatrixR)
CreateNewMatrix(*MatrixR, GetMatrixLine(*MatrixA), GetMatrixRow(*MatrixB), "ProductMatrix()")
For i = 0 To GetMatrixLine(*MatrixA) - 1
For j = 0 To GetMatrixRow(*MatrixB) - 1
For k = 0 To GetMatrixRow(*MatrixA) - 1
Sum.d = Sum + PeekMatrixElement(*MatrixA, i, k) * PeekMatrixElement(*MatrixB, k, j)
Next
SetMatrixElement(*MatrixR, i, j, Sum)
Sum = 0.0
Next
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ProductMatrixEx Operator <<<<<
Procedure ProductMatrixEx(*MatrixR.Matrix, *MatrixA.Matrix, *MatrixB.Matrix, LineStartB.u, LineStopB.u)
If GetMatrixRow(*MatrixA) = (LineStopB - LineStartB)
ResetMatrix(*MatrixR)
CreateNewMatrix(*MatrixR, GetMatrixLine(*MatrixA), GetMatrixRow(*MatrixB), "ProductMatrixEx()")
For i = 0 To GetMatrixLine(*MatrixA) - 1
For j = 0 To GetMatrixRow(*MatrixB) - 1
kB = LineStartB
For k = 0 To GetMatrixRow(*MatrixA) - 1
Sum.d = Sum + PeekMatrixElement(*MatrixA, i, k) * PeekMatrixElement(*MatrixB, kB, j)
kB + 1
Next
SetMatrixElement(*MatrixR, i, j, Sum)
Sum = 0.0
Next
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The ProductByScalar Operator <<<<<
Procedure ProductMatrixByScalar(*MatrixR.Matrix, *MatrixA.Matrix, P_Scalar.d)
If *MatrixR <> *MatrixA
ResetMatrix(*MatrixR)
CreateNewMatrix(*MatrixR, GetMatrixLine(*MatrixA), GetMatrixRow(*MatrixA), "ProductMatrixByScalar()")
EndIf
For OffsetID = 0 To GetMatrixSize(*MatrixA) - 1
PokeD(ReachMatrixElement(*MatrixR, OffsetID), PeekD(ReachMatrixElement(*MatrixA, OffsetID)) * P_Scalar)
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The TransposeMatrix Operator <<<<<
Procedure TransposeMatrix(*MatrixR.Matrix, *MatrixA.Matrix)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; It's possible to self Transpose Matrix. To do so, you just need to
; set the *MatrixR pointer equal to 0 (#Null).
;
; TransposeMatrix(MatA_Trans.Matrix, MatA.Matrix) ---> Final result 2 matrix
;
; TransposeMatrix(#Null, MatA.Matrix) ---> Final result 1 matrix
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
If *MatrixR <> #Null
CreateNewMatrix(*MatrixR, GetMatrixRow(*MatrixA), GetMatrixLine(*MatrixA), "TransposeMatrix()")
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
PokeMatrixElement(*MatrixR, RowID, LineID, PeekMatrixElement(*MatrixA, LineID, RowID))
Next
Next
Else
CopyMatrix(*MatrixA, CopyA.Matrix)
Swap GetMatrixLine(*MatrixA), GetMatrixRow(*MatrixA)
For LineID = 0 To GetMatrixLine(CopyA) - 1
For RowID = 0 To GetMatrixRow(CopyA) - 1
PokeMatrixElement(*MatrixA, RowID, LineID, PeekMatrixElement(CopyA, LineID, RowID))
Next
Next
ResetMatrix(CopyA)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The SwapMatrixLine Operator <<<<<
Procedure SwapMatrixLine(*MatrixA.Matrix, Line01.u, Line02.u)
If Line01 <= GetMatrixLine(*MatrixA) - 1 And Line02 <= GetMatrixLine(*MatrixA) - 1
For Row = 0 To GetMatrixRow(*MatrixA) - 1
E01.d = PeekMatrixElement(*MatrixA, Line01, Row)
PokeMatrixElement(*MatrixA, Line01, Row, PeekMatrixElement(*MatrixA, Line02, Row))
PokeMatrixElement(*MatrixA, Line02, Row, E01)
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The SwapMatrixRow Operator <<<<<
Procedure SwapMatrixRow(*MatrixA.Matrix, Row01.u, Row02.u)
If Row01 <= GetMatrixRow(*MatrixA) - 1 And Row02 <= GetMatrixRow(*MatrixA) - 1
For Line = 0 To GetMatrixLine(*MatrixA) - 1
E01.d = PeekMatrixElement(*MatrixA, Line, Row01)
PokeMatrixElement(*MatrixA, Line, Row01, PeekMatrixElement(*MatrixA, Line, Row02))
PokeMatrixElement(*MatrixA, Line, Row02, E01)
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The FlipMatrixLines Operator <<<<<
Procedure FlipMatrixLines(*MatrixA.Matrix)
Min.u = 0
Max.u = GetMatrixLine(*MatrixA) - 1
While Min < Max
SwapMatrixLine(*MatrixA, Min, Max)
Min + 1
Max - 1
Wend
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The FlipMatrixRows Operator <<<<<
Procedure FlipMatrixRows(*MatrixA.Matrix)
Min.u = 0
Max.u = GetMatrixRow(*MatrixA) - 1
While Min < Max
SwapMatrixRow(*MatrixA, Min, Max)
Min + 1
Max - 1
Wend
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur EvaluateLineAsPolynomialMatrix <<<<<
Procedure.d EvaluatePolynomialMatrixLine(*MatrixA.Matrix, LineID.u, P_u.d)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; This operator consider a Line as a Polynom equation. The polynom
; coefficient start fron the hightest to the lowest Exponent.
;
; Example :
;
; The polynom is : D + Cu + Bu^2 + Au^3
;
; The line appear to be like : [D, C, B, A]
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
For Row = 0 To GetMatrixRow(*MatrixA) - 1
Sum.d = Sum + PeekMatrixElement(*MatrixA, LineID, Row) * Pow(P_u, Row)
Next
ProcedureReturn Sum
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The EvaluateRowAsPolynomialMatrix Operator <<<<<
Procedure.d EvaluatePolynomialMatrixRow(*MatrixA.Matrix, RowID.u, P_u.d)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; This operator consider a Row as a Polynom equation. The polynom
; coefficient start from the hightest to the lowest Exponent.
;
; Example :
;
; The polynom is : D + Cu + Bu^2 + Au^3
;
; The line appear to be like : [D; C; B; A]
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
For Line = 0 To GetMatrixLine(*MatrixA) - 1
Sum.d = Sum + PeekMatrixElement(*MatrixA, Line, RowID) * Pow(P_u, Line)
Next
ProcedureReturn Sum
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The EvaluatePolynomialMatrix Operator <<<<<
Procedure EvaluatePolynomialMatrix(*Equations.Matrix, *U_Param.Matrix, *Result.Matrix)
ZeroMatrix(*Result, GetMatrixLine(*U_Param), GetMatrixRow(*Equations))
For U_ParamID = 0 To GetMatrixLine(*U_Param) - 1
For Line = 0 To GetMatrixLine(*Result) - 1
For Row = 0 To GetMatrixRow(*Equations) - 1
PokeMatrixElement(*Result, Line, Row, EvaluatePolynomialMatrixRow(*Equations, Row, PeekMatrixElement(*U_Param, Line, 0)))
Next
Next
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The IntegrateMatrixPolynom Operator <<<<<
Procedure IntegratePolynomialMatrix(*Integral.Matrix, *Equations.Matrix, *Cte.Matrix = #Null)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; This operator perform a polynomial integration. If the *Equation
; matrix as multiple row, each row will be processed.
;
; Example :
;
; f(x) = c + bx + ax²
; F(x) = = d + cx + 0.5bx² + 0.33ax³
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
CreateNewMatrix(*Integral, GetMatrixLine(*Equations) + 1, GetMatrixRow(*Equations), "IntegrateMatrixPolynom()")
If *Cte <> #Null
For Row = 0 To GetMatrixRow(*Equations) - 1
PokeMatrixElement(*Integral, 0, Row, PeekMatrixElement(*Cte, 0, Row))
Next
Else
For Row = 0 To GetMatrixRow(*Equations) - 1
PokeMatrixElement(*Integral, 0, Row, 0.0)
Next
EndIf
For Line = 0 To GetMatrixLine(*Equations) - 1
For Row = 0 To GetMatrixRow(*Equations) - 1
PokeMatrixElement(*Integral, Line + 1, Row, PeekMatrixElement(*Equations, Line, Row) / (Line + 1))
Next
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The DerivateMatrixPolynom Operator <<<<<
Procedure DerivatePolynomialMatrix(*Derivate.Matrix, *Equations.Matrix)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; This operator perform a polynomial derivation.If the *Equation
; matrix as multiple row, each row will be processed.
;
; Example :
;
; f(x) = d + cx + bx² + ax³
; f'(x) = c + 2bx + 3ax²
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
CreateNewMatrix(*Derivate, GetMatrixLine(*Equations) - 1, GetMatrixRow(*Equations), "DerivateMatrixPolynom()")
For Line = 0 To GetMatrixLine(*Derivate) - 1
For Row = 0 To GetMatrixRow(*Equations) - 1
SetMatrixElement(*Derivate, Line, Row, GetMatrixElement(*Equations, Line + 1, Row) * (Line + 1))
Next
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The DebugMatrix operator <<<<<
Procedure DebugMatrix(*MatrixA.Matrix, P_Decimal.b = 3)
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
Line.s = Line + StrD(PeekMatrixElement(*MatrixA, LineID, RowID), P_Decimal)
If RowID < GetMatrixRow(*MatrixA) - 1
Line + ", "
EndIf
Next
Debug "[" + Line + "]"
Line = ""
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The DebugMatrixEx operator <<<<<
Procedure DebugMatrixEx(*MatrixA.Matrix, P_Decimal.b = 3)
For OffsetID = 0 To GetMatrixSize(*MatrixA) - 1
Debug StrD(PeekD(ReachMatrixElement(*MatrixA, OffsetID)))
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The DebugAugmentedMatrixRow operator <<<<<
Procedure DebugAugmentedMatrixRow(*MatrixA.Matrix, P_FirstMatrixRowCount.u, P_Decimal.b = 3)
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
Line.s = Line + StrD(PeekMatrixElement(*MatrixA, LineID, RowID), P_Decimal)
If RowID = P_FirstMatrixRowCount - 1
Line + " | "
ElseIf RowID < GetMatrixRow(*MatrixA) - 1
Line + ", "
EndIf
Next
Debug "[" + Line + "]"
Line = ""
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The DebugAugmentedMatrixLine operator <<<<<
Procedure DebugAugmentedMatrixLine(*MatrixA.Matrix, P_FirstMatrixLineCount.u, P_Decimal.b = 3)
For LineID = 0 To P_FirstMatrixLineCount - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
Line.s = Line + StrD(PeekMatrixElement(*MatrixA, LineID, RowID), P_Decimal)
If RowID < GetMatrixRow(*MatrixA) - 1
Line + ", "
EndIf
Next
Len = Len(Line)
Debug "[" + Line + "]"
Line = ""
Next
Debug "[" + LSet("", Len, "-") + "]"
For LineID = P_FirstMatrixLineCount To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
Line.s = Line + StrD(PeekMatrixElement(*MatrixA, LineID, RowID), P_Decimal)
If RowID < GetMatrixRow(*MatrixA) - 1
Line + ", "
EndIf
Next
Len = Len(Line)
Debug "[" + Line + "]"
Line = ""
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur DebugPolynomialMatrix <<<<<
Procedure DebugPolynomialMatrix(*MatrixA.Matrix, P_Decimal.b = 3, P_Functions.s = "x(u), y(u), z(u)")
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
FunctionName.s = Trim(StringField(P_Functions, RowID + 1, ","))
VarName.s = Left(Right(FunctionName, 2), 1)
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
Coeff.s = StrD(PeekMatrixElement(*MatrixA, LineID, RowID), P_Decimal)
If LineID = 0
Equation.s = Coeff
ElseIf LineID = 1
Equation = Equation + Coeff + "·" + VarName
Else
Equation = Equation + Coeff + "·" + VarName + "^" + Str(LineID)
EndIf
If LineID < GetMatrixLine(*MatrixA) - 1
Equation + " + "
EndIf
Next
Debug FunctionName + " = " + ReplaceString(Equation, "+ -", "- ")
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Private_GaussSolverSymbolicMatrix operator <<<<<
Procedure.s Private_GaussSolverSymbolicMatrix(*MatrixA.Matrix, ValidLineCount.u, *VarFlag, P_Decimal.b = 6)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; This procedure has been programmed quickly. It is far from being fully optimized
; but it returns a result that can be easily analyzed and evaluated without much
; difficulty by a system of symbolic computation.
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
CopyMatrix(*MatrixA, CopyA.Matrix)
NewList Equations.s()
NewList FreeVars.s()
NewList Vars.s()
NewList Solution.s()
For LineID = 0 To ValidLineCount - 1
For RowID = 0 To GetMatrixRow(CopyA) - 1
If PeekMatrixElement(CopyA, LineID, RowID) <> 0.0
Break
EndIf
Next
Devider.d = PeekMatrixElement(CopyA, LineID, RowID)
For Index = RowID To GetMatrixRow(CopyA) - 1
PokeMatrixElement(CopyA, LineID, Index, PeekMatrixElement(CopyA, LineID, Index) / Devider)
Next
Next
For LineID = 0 To ValidLineCount - 1
For RowID = 0 To LastUnicodeVectorElement(*VarFlag)
Coeff.d = PeekMatrixElement(CopyA, LineID, RowID)
If Coeff <> 0.0
If PeekUnicodeVectorElement(*VarFlag, RowID) = #True
Var.s = "Mu" + Str(RowID)
ForEach FreeVars()
If FreeVars() = Var
FoundFlag = #True
Break
EndIf
Next
If FoundFlag = #False
AddElement(FreeVars())
FreeVars() = Var
Else
FoundFlag = #False
EndIf
Else
Var.s = "x" + Str(RowID + 1)
ForEach Vars()
If Vars() = Var
FoundFlag = #True
Break
EndIf
Next
If FoundFlag = #False
AddElement(Vars())
Vars() = Var
Else
FoundFlag = #False
EndIf
EndIf
Line.s = Line + StrD(Coeff, P_Decimal) + "*" + Var
If RowID < LastUnicodeVectorElement(*VarFlag)
Line + "+"
Else
Line + "=" + StrD(PeekMatrixElement(CopyA, LineID, RowID + 1), P_Decimal)
EndIf
EndIf
Next
FirstPart.s = StringField(Line, 1, "+")
FirstVar.s = StringField(FirstPart, 2,"*")
LastPart.s = Right(Line, Len(Line) - Len(FirstPart))
Cte.s = StringField(LastPart, 2, "=")
If Cte = StrD(0.0, P_Decimal)
Cte = ""
EndIf
LastVar.s = ReplaceString(ReplaceString(StringField(LastPart, 1, "="), "+", "-"), "--", "+")
AddElement(Equations())
Equations() = FirstVar + " = " + Cte + LastVar
Line = ""
Next
FirstElement(FreeVars())
FirstElement(Equations())
For Index = 0 To LastUnicodeVectorElement(*VarFlag) ; Each Equations()
If PeekUnicodeVectorElement(*VarFlag, Index) = #True
AddElement(Solution())
Solution() = FreeVars()
NextElement(FreeVars())
Else
AddElement(Solution())
Solution() = Trim(StringField(Equations(), 2, "="))
NextElement(Equations())
EndIf
Next
ForEach Solution()
ForEach Vars()
If FindString(Solution(), Vars(),1)
ForEach Equations()
If Trim(StringField(Equations(), 1, "=")) = Vars()
Break
EndIf
Next
Solution() = ReplaceString(Solution(), Vars(), "(" + Trim(StringField(Equations(), 2, "=")) + ")")
EndIf
Next
Next
ForEach Solution()
SymbolicSolution.s + Solution()
If ListIndex(Solution()) < ListSize(Solution()) - 1
SymbolicSolution.s + ";"
EndIf
Index + 1
Next
RowMax = GetMatrixRow(CopyA) - UnicodeVectorSize(*VarFlag)
LineMax = CountString(SymbolicSolution, ";")
For LineID = 0 To LineMax
Eq.s = StringField(SymbolicSolution, LineID + 1, ";")
For RowID = 0 To RowMax - 1
Eq2.s = Eq
ForEach FreeVars()
Eq2.s = ReplaceString(Eq2, FreeVars(), FreeVars() + Str(RowID + 1))
Next
SolucePart.s + Eq2
If RowID < RowMax - 1
SolucePart + ", "
EndIf
Next
FinalSoluce.s + SolucePart
SolucePart = ""
If LineID < LineMax
FinalSoluce + "; "
EndIf
Next
ClearList(Equations())
ClearList(FreeVars())
ClearList(Vars())
ClearList(Solution())
ResetMatrix(CopyA)
ProcedureReturn "[" + FinalSoluce + "]"
EndProcedure
Code : Tout sélectionner
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The GaussSolverMatrix Operator <<<<<
Procedure.b GaussSolverMatrix(*EquationSystem.Matrix, *Constant.Matrix, *Solution.Matrix)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; This Gauss Solver try to solve the system : A·X = B
;
; Do to so we have to create an augmented Matrix : [A|B] = X
; Then we try to eliminate the 1st variable in the 2nd, 3rd, 4th, ... lines
; Then we try to eliminate the 2nd variable in the 3rd, 4th, 5th, ... lines
; and so on until all line is processed.
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Initialize the Solution Matrix
ZeroMatrix(*Solution, GetMatrixRow(*EquationSystem), GetMatrixRow(*Constant))
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Merge EquationSystem and Constant to create the Augmented Matrix
AugmentMatrixRow(Augmented.Matrix, *EquationSystem.Matrix, *Constant.Matrix)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Application of elementary line operations to obtain the equavalent echelon matrix
For Oper = 0 To GetMatrixLine(Augmented) - 2
S1.d = PeekMatrixElement(Augmented, Oper, Oper)
For LineID = Oper + 1 To GetMatrixLine(Augmented) - 1
S2.d = PeekMatrixElement(Augmented, LineID, Oper)
For RowID = 0 To GetMatrixRow(Augmented) - 1
PokeMatrixElement(Augmented, LineID, RowID, S1 * PeekMatrixElement(Augmented, LineID, RowID) - S2 * PeekMatrixElement(Augmented, Oper, RowID))
Next
Next
Next
; DebugAugmentedMatrixRow(Augmented, GetMatrixRow(*EquationSystem), 4)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Now we scan the matrix to verify if the system has single or infinite solution
; or if the system is impossible to solve. To do this, we try to find an impossible
; equation like : 0·x1 + 0·x2 + 0·x3 + 0·x4 = 10
For LineID = 0 To GetMatrixLine(Augmented) - 1
For RowID = 0 To GetMatrixRow(*EquationSystem) - 1
Sum.d = Sum + Abs(PeekMatrixElement(Augmented, LineID, RowID))
Next
If Sum <> 0.0
NotEmptyLineCount + 1
EndIf
For RowID2 = GetMatrixRow(*EquationSystem) To GetMatrixRow(Augmented) - 1
If Sum = 0.0
If PeekMatrixElement(Augmented, LineID, RowID2) <> Sum
ResetMatrix(*Solution)
ResetMatrix(Augmented)
ProcedureReturn #GAUSS_SOLVER_IMPOSSIBLE_SOLUTION
EndIf
EndIf
Next
Sum = 0.0
Next
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Now we have two possibility, the Not empty line count match the variable count,
; the solution is unique. The other possibility, we have some Free variables in the
; system. So we have to find them before to solve the system.
If NotEmptyLineCount = GetMatrixRow(*EquationSystem)
; The Not empty line count equal the Variable count, the solution is unique
SoluceMax = GetMatrixLine(*Solution) - 1
For SolutionRowID = 0 To GetMatrixRow(*Solution) - 1
For SoluceLineID = SoluceMax To 0 Step -1
If SoluceLineID = SoluceMax
Sum.d = 0.0
Else
For RowID = SoluceLineID + 1 To SoluceMax
Sum = Sum + PeekMatrixElement(Augmented, SoluceLineID, RowID) * PeekMatrixElement(*Solution, RowID, SolutionRowID)
Next
EndIf
PokeMatrixElement(*Solution, SoluceLineID, SolutionRowID, (PeekMatrixElement(Augmented, SoluceLineID, GetMatrixRow(*EquationSystem) + SolutionRowID) - Sum) / PeekMatrixElement(Augmented, SoluceLineID, SoluceLineID))
Sum = 0.0
Next
Next
SolverSuccess.b = #GAUSS_SOLVER_SINGLE_SOLUTION
Else
SoluceMax = NotEmptyLineCount - 1
; Debug "Presence of " + Str(GetMatrixRow(*EquationSystem) - NotEmptyLineCount) + " free variables"
For SolutionRowID = 0 To GetMatrixRow(*Solution) - 1
For LineID = NotEmptyLineCount - 1 To 0 Step - 1
For RowID = 0 To GetMatrixRow(*EquationSystem) - 1 ; This loop is used to find the first linked variable
If PeekMatrixElement(Augmented, LineID, RowID) <> 0.0
Break
EndIf
Next
For RowID2 = RowID + 1 To GetMatrixRow(*EquationSystem) - 1
Sum.d = Sum + PeekMatrixElement(Augmented, LineID, RowID2) * PeekMatrixElement(*Solution, RowID2, SolutionRowID)
Next
PokeMatrixElement(*Solution, RowID, SolutionRowID, (PeekMatrixElement(Augmented, LineID, GetMatrixRow(*EquationSystem) + SolutionRowID) - Sum) / PeekMatrixElement(Augmented, LineID, RowID))
Next
Next
SolverSuccess = #GAUSS_SOLVER_INFINITE_SOLUTION
EndIf
ResetMatrix(Augmented)
ProcedureReturn SolverSuccess
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The GaussSolverMatrixEx Operator <<<<<
Procedure.s GaussSolverMatrixEx(*EquationSystem.Matrix, *Constant.Matrix, *Solution.Matrix, P_Decimal.b = 6)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; This Gauss Solver try to solve the system : A·X = B
;
; Do to so we have to create an augmented Matrix : [A|B] = X
; Then we try to eliminate the 1st variable in the 2nd, 3rd, 4th, ... lines
; Then we try to eliminate the 2nd variable in the 3rd, 4th, 5th, ... lines
; and so on until all line is processed.
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Initialize the Solution Matrix
ZeroMatrix(*Solution, GetMatrixRow(*EquationSystem), GetMatrixRow(*Constant))
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Merge EquationSystem and Constant to create the Augmented Matrix
AugmentMatrixRow(Augmented.Matrix, *EquationSystem.Matrix, *Constant.Matrix)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Application of elementary line operations to obtain the equavalent echelon matrix
For Oper = 0 To GetMatrixLine(Augmented) - 2
S1.d = PeekMatrixElement(Augmented, Oper, Oper)
For LineID = Oper + 1 To GetMatrixLine(Augmented) - 1
S2.d = PeekMatrixElement(Augmented, LineID, Oper)
For RowID = 0 To GetMatrixRow(Augmented) - 1
PokeMatrixElement(Augmented, LineID, RowID, S1 * PeekMatrixElement(Augmented, LineID, RowID) - S2 * PeekMatrixElement(Augmented, Oper, RowID))
Next
Next
Next
; DebugAugmentedMatrixRow(Augmented, GetMatrixRow(*EquationSystem), 4)
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Now we scan the matrix to verify if the system has single or infinite solution
; or if the system is impossible to solve.
For LineID = 0 To GetMatrixLine(Augmented) - 1
For RowID = 0 To GetMatrixRow(*EquationSystem) - 1
Sum.d = Sum + Abs(PeekMatrixElement(Augmented, LineID, RowID))
Next
If Sum <> 0.0
NotEmptyLineCount + 1
EndIf
For RowID2 = GetMatrixRow(*EquationSystem) To GetMatrixRow(Augmented) - 1
If Sum = 0.0
If PeekMatrixElement(Augmented, LineID, RowID2) <> Sum
ResetMatrix(*Solution)
ResetMatrix(Augmented)
ProcedureReturn "IMPOSSIBLE"
EndIf
EndIf
Next
Sum = 0.0
Next
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Now we have two possibility, the Not empty line count match the variable count,
; the solution is unique. The other possibility, we have some Free variables in the
; system. So we have to find them before to solve the system.
If NotEmptyLineCount = GetMatrixRow(*EquationSystem)
; The Not empty line count equal the Variable count, the solution is unique
SoluceMax = GetMatrixLine(*Solution) - 1
For SolutionRowID = 0 To GetMatrixRow(*Solution) - 1
For SoluceLineID = SoluceMax To 0 Step -1
If SoluceLineID = SoluceMax
Sum.d = 0.0
Else
For RowID = SoluceLineID + 1 To SoluceMax
Sum = Sum + PeekMatrixElement(Augmented, SoluceLineID, RowID) * PeekMatrixElement(*Solution, RowID, SolutionRowID)
Next
EndIf
PokeMatrixElement(*Solution, SoluceLineID, SolutionRowID, (PeekMatrixElement(Augmented, SoluceLineID, GetMatrixRow(*EquationSystem) + SolutionRowID) - Sum) / PeekMatrixElement(Augmented, SoluceLineID, SoluceLineID))
Sum = 0.0
Next
Next
GeneralSolution.s = Matrix_To_String(*Solution, P_Decimal)
Else
VarFlag = NewUnicodeVector(GetMatrixRow(*EquationSystem))
SoluceMax = NotEmptyLineCount - 1
; Debug "Presence of " + Str(GetMatrixRow(*EquationSystem) - NotEmptyLineCount) + " free variables"
For LineID = 0 To NotEmptyLineCount - 1
For RowID = 0 To GetMatrixRow(*EquationSystem) - 1
If PeekMatrixElement(Augmented, LineID, RowID) <> 0.0
Break
EndIf
Next
For Index = RowID To GetMatrixRow(*EquationSystem) - 1
If Index = RowID
PokeUnicodeVectorElement(VarFlag, Index, #False)
Else
PokeUnicodeVectorElement(VarFlag, Index, #True)
EndIf
Next
Next
For SolutionRowID = 0 To GetMatrixRow(*Solution) - 1
For LineID = NotEmptyLineCount - 1 To 0 Step - 1
For RowID = 0 To GetMatrixRow(*EquationSystem) - 1
If PeekMatrixElement(Augmented, LineID, RowID) <> 0.0
Break
EndIf
Next
For RowID2 = RowID + 1 To GetMatrixRow(*EquationSystem) - 1
Sum.d = Sum + PeekMatrixElement(Augmented, LineID, RowID2) * PeekMatrixElement(*Solution, RowID2, SolutionRowID)
Next
PokeMatrixElement(*Solution, RowID, SolutionRowID, (PeekMatrixElement(Augmented, LineID, GetMatrixRow(*EquationSystem) + SolutionRowID) - Sum) / PeekMatrixElement(Augmented, LineID, RowID))
Next
Next
GeneralSolution = Private_GaussSolverSymbolicMatrix(Augmented, NotEmptyLineCount, VarFlag, P_Decimal)
DeleteUnicodeVector(VarFlag)
EndIf
ResetMatrix(Augmented)
ProcedureReturn GeneralSolution
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The GaussJordanInverse Operator <<<<<
Procedure.b GaussJordanInverseMatrix(*Inverse.Matrix, *MatrixA.Matrix)
If GetMatrixLine(*MatrixA) = GetMatrixRow(*MatrixA)
Result.b = #True
CopyMatrix(*MatrixA, CopyA.Matrix)
IdentityMatrix(*Inverse, GetMatrixLine(*MatrixA))
If PeekMatrixElement(CopyA, 0, 0) = 0.0
If PeekMatrixElement(CopyA, GetMatrixLine(*MatrixA) - 1, 0) <> 0.0
; Debug "On additonne la dernière ligne à la première"
For Row = 0 To GetMatrixRow(*MatrixA) - 1
PokeMatrixElement(CopyA, 0, Row, PeekMatrixElement(CopyA, 0, Row) + PeekMatrixElement(CopyA, GetMatrixLine(*MatrixA) - 1, Row))
PokeMatrixElement(*Inverse, 0, Row, PeekMatrixElement(*Inverse, 0, Row) + PeekMatrixElement(*Inverse, GetMatrixLine(*MatrixA) - 1, Row))
Next
Else
; Debug "La matrice est singulière 1"
ResetMatrix(CopyA)
ResetMatrix(*Inverse)
ProcedureReturn #False
EndIf
EndIf
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Manipulation afin d'avoir des zéros sous la diagonale.
For Oper = 0 To GetMatrixLine(*MatrixA) - 2
S1.d = PeekMatrixElement(CopyA, Oper, Oper)
For LineID = Oper + 1 To GetMatrixLine(*MatrixA) - 1
S2.d = PeekMatrixElement(CopyA, LineID, Oper)
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
PokeMatrixElement(CopyA, LineID, RowID, S1 * PeekMatrixElement(CopyA, LineID, RowID) - S2 * PeekMatrixElement(CopyA, Oper, RowID))
PokeMatrixElement(*Inverse, LineID, RowID, S1 * PeekMatrixElement(*Inverse, LineID, RowID) - S2 * PeekMatrixElement(*Inverse, Oper, RowID))
Next
Next
Next
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Manipulation afin d'avoir des zéros au dessus de la diagonale.
For Oper = GetMatrixLine(*MatrixA) - 1 To 1 Step - 1
S1.d = PeekMatrixElement(CopyA, Oper, Oper)
For LineID = Oper - 1 To 0 Step -1
S2.d = PeekMatrixElement(CopyA, LineID, Oper)
For RowID = GetMatrixLine(*MatrixA) - 1 To 0 Step -1
PokeMatrixElement(CopyA, LineID, RowID, S1 * PeekMatrixElement(CopyA, LineID, RowID) - S2 * PeekMatrixElement(CopyA, Oper, RowID))
PokeMatrixElement(*Inverse, LineID, RowID, S1 * PeekMatrixElement(*Inverse, LineID, RowID) - S2 * PeekMatrixElement(*Inverse, Oper, RowID))
Next
Next
Next
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Normalisation par rapport à la diagonale
For Line = 0 To GetMatrixRow(*MatrixA) - 1
Pivot.d = PeekMatrixElement(CopyA, Line, Line)
If Pivot <> 0.0
For Row = 0 To GetMatrixRow(*MatrixA) - 1
PokeMatrixElement(CopyA, Line, Row, PeekMatrixElement(CopyA, Line, Row) / Pivot)
PokeMatrixElement(*Inverse, Line, Row, PeekMatrixElement(*Inverse, Line, Row) / Pivot)
Next
Else
ResetMatrix(CopyA)
ResetMatrix(*Inverse)
Result = #False
Break
EndIf
Next
Else
; La matrice n'est pas carrée
Result = #False
EndIf
ProcedureReturn Result
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The LUDecomposeMatrix Operator <<<<<
Procedure.b LUDecomposeMatrix(*MatrixA.Matrix, *L.Matrix, *U.matrix)
If GetMatrixLine(*MatrixA) = GetMatrixRow(*MatrixA)
CopyMatrix(*MatrixA, *U)
IdentityMatrix(*L, GetMatrixLine(*MatrixA))
LUDecomposeSuccess.b = #True
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Manipulation afin d'avoir des zéros sous la diagonale.
For Oper = 0 To GetMatrixLine(*MatrixA) - 2
For Line = Oper + 1 To GetMatrixLine(*MatrixA) - 1
If PeekMatrixElement(*MatrixA, Oper, Oper) <> 0.0
Fract.d = PeekMatrixElement(*U, Line, Oper) / PeekMatrixElement(*U, Oper, Oper)
PokeMatrixElement(*L, Line, Oper, Fract)
For Row = 0 To GetMatrixLine(*MatrixA) - 1
PokeMatrixElement(*U, Line, Row, PeekMatrixElement(*U, Line, Row) - Fract * PeekMatrixElement(*U, Oper, Row))
Next
Else
; Debug "La matrice est singulière"
ResetMatrix(*U)
ResetMatrix(*L)
LUDecomposeSuccess.b = #False
Break 2
EndIf
Next
Next
EndIf
ProcedureReturn LUDecomposeSuccess
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The DeterminantMatrix Operator <<<<<
Procedure.d DeterminantMatrix(*MatrixA.Matrix)
If GetMatrixLine(*MatrixA) = GetMatrixRow(*MatrixA)
Result.b = #True
CopyMatrix(*MatrixA, CopyA.Matrix)
If PeekMatrixElement(CopyA, 0, 0) = 0.0
If PeekMatrixElement(CopyA, GetMatrixLine(*MatrixA) - 1, Row) <> 0.0
; On additonne la dernière ligne à la première
For Row = 0 To GetMatrixRow(*MatrixA) - 1
PokeMatrixElement(CopyA, 0, Row, PeekMatrixElement(CopyA, 0, Row) + PeekMatrixElement(CopyA, GetMatrixLine(*MatrixA) - 1, Row))
Next
Else
; La matrice n'est pas inversible
Determinant.d = 0.0
Result = #False
EndIf
EndIf
If Result = #True
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Manipulation afin d'avoir des zéros sous la diagonale.
For Oper = 0 To GetMatrixLine(*MatrixA) - 2
For Line = Oper + 1 To GetMatrixLine(*MatrixA) - 1
If PeekMatrixElement(CopyA, Oper, Oper) <> 0.0
Fract.d = PeekMatrixElement(CopyA, Line, Oper) / PeekMatrixElement(CopyA, Oper, Oper)
For Row = 0 To GetMatrixLine(*MatrixA) - 1
PokeMatrixElement(CopyA, Line, Row, PeekMatrixElement(CopyA, Line, Row) - Fract * PeekMatrixElement(CopyA, Oper, Row))
Next
Else
; La matrice est singulière
Result = #False
Break 2
EndIf
Next
Next
EndIf
If Result = #True
Determinant = 1.0
For Line = 0 To GetMatrixLine(*MatrixA) - 1
Determinant = Determinant * PeekMatrixElement(CopyA, Line, Line)
Next
Else
Determinant = 0.0
EndIf
Else
; La matrice n'est pas carrée
Determinant = 0.0
EndIf
ResetMatrix(CopyA)
ProcedureReturn Determinant
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Read in Binary file <<<<<
Procedure ReadMatrix(FileID.l, *MatrixA.Matrix)
SetMatrixLine(*MatrixA, ReadUnicodeCharacter(FileID))
SetMatrixRow(*MatrixA, ReadUnicodeCharacter(FileID))
SetMatrixSize(*MatrixA, ReadLong(FileID))
AllocateMatrixElementsMemory(*MatrixA)
If GetMatrixElements(*MatrixA) = #Null
MessageRequester("Fatal Error", "ReadMatrix() - Impossible To Allocate Memory !")
End
Else
ReadData(FileID, GetMatrixElements(*MatrixA), MemoryMatrixElementsSize(*MatrixA))
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Write in Binary file <<<<<
Procedure WriteMatrix(FileID.l, *MatrixA.Matrix)
WriteUnicodeCharacter(FileID, GetMatrixLine(*MatrixA))
WriteUnicodeCharacter(FileID, GetMatrixRow(*MatrixA))
WriteLong(FileID, GetMatrixSize(*MatrixA))
If GetMatrixElements(*MatrixA) <> #Null
WriteData(FileID, GetMatrixElements(*MatrixA), MemoryMatrixElementsSize(*MatrixA))
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Set - Noeud avec noeuds enfants <<<<<
Procedure SetMatrixXMLNode(CurrentNode, *MatrixA.Matrix, P_Decimal.b = 6)
If ParentXMLNode(CurrentNode) = #Null
StructNode = CreateXMLNode(CurrentNode)
SetXMLNodeName(StructNode, "Matrix")
SetXMLAttribute(StructNode, "LineCount", Str(GetMatrixLine(*MatrixA)))
SetXMLAttribute(StructNode, "RowCount", Str(GetMatrixRow(*MatrixA)))
Else
StructNode = CurrentNode
EndIf
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
FieldNode = CreateXMLNode(StructNode)
SetXMLNodeName(FieldNode, "Line" + Str(LineID + 1))
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
SetXMLAttribute(FieldNode, "L" + Str(LineID + 1) + "_R" + Str(RowID + 1), StrD(PeekMatrixElement(*MatrixA, LineID, RowID), P_Decimal))
Next
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Get - Noeud avec noeuds enfants <<<<<
Procedure GetMatrixXMLNode(CurrentNode, *MatrixA.Matrix)
If ParentXMLNode(CurrentNode) = #Null
StructNode = ChildXMLNode(CurrentNode)
If GetXMLNodeName(StructNode) = "Matrix"
Success = #True
EndIf
Else
Success = #True
StructNode = CurrentNode
EndIf
If Success = #True
LineCount.u = Val(GetXMLAttribute(StructNode, "LineCount"))
RowCount.u = Val(GetXMLAttribute(StructNode, "RowCount"))
ZeroMatrix(*MatrixA, LineCount, RowCount)
FieldNode = ChildXMLNode(StructNode)
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
PokeMatrixElement(*MatrixA, LineID, RowID, ValD_Patch_PB(GetXMLAttribute(FieldNode, "L" + Str(LineID + 1) + "_R" + Str(RowID + 1))))
Next
FieldNode = NextXMLNode(FieldNode)
Next
EndIf
ProcedureReturn Success
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Create XML file <<<<<
Procedure CreateMatrixXMLFile(FileID.l, FileName.s, *MatrixA.Matrix)
If CreateXML(FileID)
SetMatrixXMLNode(RootXMLNode(FileID), *MatrixA)
FormatXML(FileID, #PB_XML_ReFormat | #PB_XML_ReIndent)
SaveXML(FileID, FileName)
FreeXML(FileID)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Load XML file <<<<<
Procedure LoadMatrixXMLFile(FileID.l, FileName.s, *MatrixA.Matrix)
If LoadXML(FileID, FileName)
FormatXML(FileID, #PB_XML_CutNewline)
GetMatrixXMLNode(RootXMLNode(FileID), *MatrixA)
FreeXML(FileID)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Catch XML file <<<<<
Procedure CatchMatrixXMLFile(FileID.l, *Buffer, BufferSize.l, *MatrixA.Matrix)
If CatchXML(FileID, *Buffer, BufferSize)
FormatXML(FileID, #PB_XML_CutNewline)
GetMatrixXMLNode(RootXMLNode(FileID), *MatrixA)
FreeXML(FileID)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Read preferences Matrix <<<<<
Procedure ReadPreferenceMatrix(Keyword.s, *MatrixA.Matrix, DefaultMatrix.s = "[0.0]")
String_To_Matrix(*MatrixA, ReadPreferenceString(Keyword, DefaultMatrix))
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Write preferences Matrix <<<<<
Procedure WritePreferenceMatrix(Keyword.s, *MatrixA.Matrix, P_Decimal.b = 6)
WritePreferenceString(Keyword, Matrix_To_String(*MatrixA.Matrix, P_Decimal))
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Save Matrix To CSV File <<<<<
Procedure SaveMatrixToCSVFile(FileID.l, FileName.s, *MatrixA.Matrix, P_Decimal.b = 6)
If CreateFile(FileID, FileName)
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
Line.s = Line + StrD(PeekMatrixElement(*MatrixA, LineID, RowID), P_Decimal)
If RowID < GetMatrixRow(*MatrixA) - 1
Line + ";"
EndIf
Next
WriteStringN(FileID, Line)
Line = ""
Next
CloseFile(FileID)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Load Matrix From CSV File <<<<<
Procedure LoadMatrixFromCSVFile(FileID.l, FileName.s, *MatrixA.Matrix)
NewList CSVLine.s()
If ReadFile(FileID, FileName)
While Eof(FileID) = 0
Line.s = Trim(ReadString(FileID))
If Line <> ""
AddElement(CSVLine())
CSVLine() = Line
EndIf
Wend
CloseFile(FileID)
EndIf
FirstElement(CSVLine())
Max = CountString(CSVLine(), ";")
ZeroMatrix(*MatrixA, ListSize(CSVLine()), Max + 1)
ForEach CSVLine()
For RowID = 0 To Max
PokeMatrixElement(*MatrixA, LineID, RowID, ValD_Patch_PB(StringField(CSVLine(), RowID + 1, ";")))
Next
LineID + 1
CSVLine() = ""
Next
ClearList(CSVLine())
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Trefoil Knot Waypoint Matrix Operator : 3D Curves <<<<<
Procedure TrefoilKnotWaypointMatrix(*InterpolationValue.Matrix, *Path.Matrix, P_LeafCount.l = 3, P_e.l = 1)
ZeroMatrix(*Path, GetMatrixLine(*InterpolationValue), 3)
For U_ParamID = 0 To GetMatrixLine(*InterpolationValue) - 1
P_u.d = PeekMatrixElement(*InterpolationValue, U_ParamID, 0)
PokeMatrixElement(*Path, U_ParamID, 0, Cos(P_u) + 2 * Cos(P_LeafCount * P_u - P_u))
PokeMatrixElement(*Path, U_ParamID, 1, Sin(P_u) - 2 * Sin(P_LeafCount * P_u - P_u))
PokeMatrixElement(*Path, U_ParamID, 2, 2 * P_e * Sin(P_LeafCount * P_u))
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The LagrangePolynomialMatrix Operator <<<<<
Procedure LagrangePolynomialMatrix(P_PointCount.u, *Coefficient.Matrix, *CoefficientInverse.Matrix)
ZeroMatrix(*Coefficient, P_PointCount, P_PointCount)
Increment.d = 1 / (P_PointCount - 1)
For Row = 0 To GetMatrixRow(*Coefficient) - 1
Var.d = 0.0
For Line = 0 To GetMatrixLine(*Coefficient) - 1
PokeMatrixElement(*Coefficient, Line, Row, Pow(Var, Row))
Var + Increment
Next
Next
GaussJordanInverseMatrix(*CoefficientInverse, *Coefficient)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The LagrangePathFromWaypoints Operator <<<<<
Procedure LagrangePathFromWaypoints(*Waypoint.Matrix, *InterpolationValue.Matrix, *Path.Matrix)
LagrangePolynomialMatrix(GetMatrixLine(*Waypoint), Lagrange.Matrix, LagrangeInverse.Matrix)
ProductMatrix(Equations.Matrix, LagrangeInverse, *Waypoint)
EvaluatePolynomialMatrix(Equations, *InterpolationValue, *Path)
ResetMatrix(Lagrange)
ResetMatrix(LagrangeInverse)
ResetMatrix(Equations)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The CatmullRomInverseCoefficient Operator <<<<<
Procedure CatmullRomInverseCoefficient(*InverseCoeff.Matrix)
CreateNewMatrix(*InverseCoeff, 4, 4, "CatmullRomInverseCoefficient()")
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 1 <<<<<<
PokeMatrixElement(*InverseCoeff, 0, 0, 0.0)
PokeMatrixElement(*InverseCoeff, 0, 1, 1.0)
PokeMatrixElement(*InverseCoeff, 0, 2, 0.0)
PokeMatrixElement(*InverseCoeff, 0, 3, 0.0)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 2 <<<<<<
PokeMatrixElement(*InverseCoeff, 1, 0, -0.5)
PokeMatrixElement(*InverseCoeff, 1, 1, 0.0)
PokeMatrixElement(*InverseCoeff, 1, 2, 0.5)
PokeMatrixElement(*InverseCoeff, 1, 3, 0.0)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 3 <<<<<<
PokeMatrixElement(*InverseCoeff, 2, 0, 1.0)
PokeMatrixElement(*InverseCoeff, 2, 1, -2.5)
PokeMatrixElement(*InverseCoeff, 2, 2, 2.0)
PokeMatrixElement(*InverseCoeff, 2, 3, -0.5)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 4 <<<<<<
PokeMatrixElement(*InverseCoeff, 3, 0, -0.5)
PokeMatrixElement(*InverseCoeff, 3, 1, 1.5)
PokeMatrixElement(*InverseCoeff, 3, 2, -1.5)
PokeMatrixElement(*InverseCoeff, 3, 3, 0.5)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The CatmullRomPathFromWaypoint Operator <<<<<
Procedure CatmullRomPathFromWaypoint(*Waypoint.Matrix, *InterpolationValue.Matrix, *Path.Matrix)
CatmullRomInverseCoefficient(CatmullKInv.Matrix)
ProductMatrix(Equations.Matrix, CatmullKInv, *Waypoint)
EvaluatePolynomialMatrix(Equations, *InterpolationValue, *Path)
ResetMatrix(CatmullKInv)
ResetMatrix(Equations)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The CatmullRomPathFusion Operator <<<<<
Procedure CatmullRomPathFusion(*Fusion.Matrix, *PathA.Matrix, *PathB.Matrix)
If GetMatrixRow(*PathA) = GetMatrixRow(*PathB)
ZeroMatrix(*Fusion, GetMatrixLine(*PathA) + GetMatrixLine(*PathB) - 1, GetMatrixRow(*PathA))
CopyMemory(GetMatrixElements(*PathA), GetMatrixElements(*Fusion), MemoryMatrixElementsSize(*PathA) - 3 * SizeOf(Double))
CopyMemory(GetMatrixElements(*PathB), GetMatrixElements(*Fusion) + MemoryMatrixElementsSize(*PathA) - 3 * SizeOf(Double), MemoryMatrixElementsSize(*PathB))
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The CatmullRomInsertWaypoint Operator <<<<<
Procedure CatmullRomInsertWaypoint(*Waypoint.Matrix, *NewPoint.Matrix)
If GetMatrixRow(*Waypoint) = GetMatrixRow(*NewPoint)
For LineID = 1 To GetMatrixLine(*Waypoint) - 1
For RowID = 0 To GetMatrixRow(*Waypoint) - 1
PokeMatrixElement(*Waypoint, LineID - 1, RowID, PeekMatrixElement(*Waypoint, LineID, RowID))
If LineID = GetMatrixLine(*Waypoint) - 1
PokeMatrixElement(*Waypoint, LineID, RowID, PeekMatrixElement(*NewPoint, 0, RowID))
EndIf
Next
Next
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The InitializeHermite Operator <<<<<
Procedure HermiteInverseCoefficient(*InverseCoeff.Matrix)
CreateNewMatrix(*InverseCoeff, 4, 4, "HermiteInverseCoefficient()")
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 1 <<<<<<
PokeMatrixElement(*InverseCoeff, 0, 0, 1.0)
PokeMatrixElement(*InverseCoeff, 0, 1, 0.0)
PokeMatrixElement(*InverseCoeff, 0, 2, 0.0)
PokeMatrixElement(*InverseCoeff, 0, 3, 0.0)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 2 <<<<<<
PokeMatrixElement(*InverseCoeff, 1, 0, 0.0)
PokeMatrixElement(*InverseCoeff, 1, 1, 0.0)
PokeMatrixElement(*InverseCoeff, 1, 2, 1.0)
PokeMatrixElement(*InverseCoeff, 1, 3, 0.0)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 3 <<<<<<
PokeMatrixElement(*InverseCoeff, 2, 0, -3.0)
PokeMatrixElement(*InverseCoeff, 2, 1, 3.0)
PokeMatrixElement(*InverseCoeff, 2, 2, -2.0)
PokeMatrixElement(*InverseCoeff, 2, 3, -1.0)
; <<<<<<<<<<<<<<<<<<<<
; <<<<< Ligne 4 <<<<<<
PokeMatrixElement(*InverseCoeff, 3, 0, 2.0)
PokeMatrixElement(*InverseCoeff, 3, 1, -2.0)
PokeMatrixElement(*InverseCoeff, 3, 2, 1.0)
PokeMatrixElement(*InverseCoeff, 3, 3, 1.0)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The De Casteljau Matrix <<<<<
Procedure DeCasteljauMatrix(Order.u, *D_Zero.Matrix, *D_One.Matrix)
If Order >= 2
ZeroMatrix(*D_Zero, Order, Order)
For RowID = 0 To Order - 1
For LineID = 0 To Order - 1
If RowID <= LineID
PokeMatrixElement(*D_Zero, LineID, RowID, BernsteinPolynomial(LineID, RowID, 0.5))
Else
PokeMatrixElement(*D_Zero, LineID, RowID, 0.0)
EndIf
Next
Next
CopyMatrix(*D_Zero, *D_One)
Min.u = 0
Max.u = Order - 1
While Min < Max
SwapMatrixLine(*D_One, Min, Max)
SwapMatrixRow(*D_One, Min, Max)
Min + 1
Max - 1
Wend
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The BezierPathFromControlpoints Operator <<<<<
Procedure BezierPathFromControlpoints(*Controlpoint.Matrix, *InterpolationValue.Matrix, *Path.Matrix)
ZeroMatrix(*Path, GetMatrixLine(*InterpolationValue), GetMatrixRow(*Controlpoint))
For U_ID = 0 To GetMatrixLine(*InterpolationValue) - 1
For RowID = 0 To GetMatrixRow(*Controlpoint) - 1
For LineID = 0 To GetMatrixLine(*Controlpoint) - 1
Sum.d = Sum + BernsteinPolynomial(GetMatrixLine(*Controlpoint) - 1, LineID, PeekMatrixElement(*InterpolationValue, U_ID, 0)) * PeekMatrixElement(*Controlpoint, LineID, RowID)
Next
PokeMatrixElement(*Path, U_ID, RowID, Sum)
Sum = 0.0
Next
Next
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : General Maths Matrix Calculation
; File Name : Maths Matrix Calculation - Demo.pb
; File version: 1.0.0
; Programmation : OK - In progress
; Programmed by : Guimauve
; Date : 04-08-2011
; Last Update : 19-08-2011
; PureBasic code : 4.60
; Plateform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
IncludeFile "Maths Matrix Calculation.pb"
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Identity Matrix (A)"
IdentityMatrix(MatA.Matrix, 5)
DebugMatrix(MatA, 1)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Zero Matrix (0.0 all over the place)"
ZeroMatrix(Zero55.Matrix, 5, 5)
DebugMatrix(Zero55, 1)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; One Matrix (1.0 all over the place)"
OneMatrix(One55.Matrix, 5, 5)
DebugMatrix(One55, 1)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Rotate around X axis Matrix"
RotateXMatrix3D(RotateX.Matrix, #PI/6)
DebugMatrix(RotateX)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Rotate around Y axis Matrix"
RotateYMatrix3D(RotateY.Matrix, #PI/6)
DebugMatrix(RotateY)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Rotate around Z axis Matrix"
RotateZMatrix3D(RotateZ.Matrix, #PI/6)
DebugMatrix(RotateZ)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Mirror X plane Matrix"
MirrorXMatrix3D(MirrorX.Matrix)
DebugMatrix(MirrorX)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Mirror Y plane Matrix"
MirrorYMatrix3D(MirrorY.Matrix)
DebugMatrix(MirrorY)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Mirror Z plane Matrix"
MirrorZMatrix3D(MirrorZ.Matrix)
DebugMatrix(MirrorZ)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Translation Matrix"
TranslationMatrix3D(Translation.Matrix, 5.5,10.5, 7.5)
DebugMatrix(Translation)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Scale Matrix"
ScaleMatrix3D(Scale.Matrix, 2.0,3.0, 2.5)
DebugMatrix(Scale)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Tridiagonal Matrix"
TridiagonalMatrix(TridiagonalMatrix.Matrix, 6, 5.0)
DebugMatrix(TridiagonalMatrix, 1)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Tridiagonal Matrix Ex"
String_To_Matrix(Diagonal.Matrix, "[5.0, 4.0, 4.0, 4.0, 4.0, 5.0]")
TridiagonalMatrixEx(TridiagonalMatrixEx.Matrix, Diagonal)
DebugMatrix(TridiagonalMatrixEx, 1)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Random Matrix"
RandomMatrix(RandomMatrix.Matrix, 4, 4, -9.0, 9.0)
DebugMatrix(RandomMatrix)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Random Matrix Inverse"
If GaussJordanInverseMatrix(InvRandomMatrix.Matrix, RandomMatrix)
DebugMatrix(InvRandomMatrix, 4)
Else
Debug "Singular Matrix : Det(RandomMatrix) = " + StrD(DeterminantMatrix(RandomMatrix), 4)
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Random Matrix Diagonal"
ExtractMatrixDiagonal(Diagonal.Matrix, RandomMatrix)
DebugMatrix(Diagonal)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Random Matrix Line 2"
ExtractMatrixLine(2, Line2.Matrix, RandomMatrix)
DebugMatrix(Line2)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Random Matrix Row 2"
ExtractMatrixRow(2, Row2.Matrix, RandomMatrix)
DebugMatrix(Row2)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Flip Random Matrix Lines"
DebugMatrix(RandomMatrix)
Debug ""
FlipMatrixLines(RandomMatrix)
DebugMatrix(RandomMatrix)
FlipMatrixLines(RandomMatrix)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Flip Random Matrix Rows"
DebugMatrix(RandomMatrix)
Debug ""
FlipMatrixRows(RandomMatrix)
DebugMatrix(RandomMatrix)
FlipMatrixRows(RandomMatrix)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Matrix from String (B)"
String_To_Matrix(MatB.Matrix, "[-2,3,-1;5,0,2;1,-1,2]")
DebugMatrix(MatB)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; String from Matrix (B)"
Debug Matrix_To_String(MatB, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Déterminant of matrix B"
Debug DeterminantMatrix(MatB)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Matrix Produit by scalar (B * s)"
ProductMatrixByScalar(MatBS.Matrix, MatB, #PI)
DebugMatrix(MatBS)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; PlusMatrix (C = B + Bs)"
PlusMatrix(MatC.Matrix, MatB, MatBS)
DebugMatrix(MatC)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; AddMatrix (C = C + BS)"
Debug "; AddMatrix (C = C + B)"
AddMatrix(MatCC.Matrix, MatBS)
AddMatrix(MatCC, MatB)
DebugMatrix(MatCC)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; MinusMatrix (D = C - Bs)"
MinusMatrix(MatD.Matrix, MatC, MatBS)
DebugMatrix(MatD)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; SubstractMatrix (D = D - C)"
Debug "; SubstractMatrix (D = D - Bs)"
SubstractMatrix(MatDD.Matrix, MatC)
SubstractMatrix(MatDD, MatBS)
DebugMatrix(MatDD)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Matrix Produit (B*B)"
ProductMatrix(MatBB.Matrix, MatB, MatB)
DebugMatrix(MatBB)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Transpose Matrix (Duplicate) (BBT^T)"
TransposeMatrix(MatBBT.Matrix, MatBB)
DebugMatrix(MatBBT)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Transpose Matrix (In place) (BBT^T)"
TransposeMatrix(#Null, MatBBT)
DebugMatrix(MatBBT)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Inverse Matrix (B^-1)"
If GaussJordanInverseMatrix(InvB.Matrix, MatB)
DebugMatrix(InvB, 4)
Else
Debug "Singular Matrix : Det(MatB) = " + StrD(DeterminantMatrix(MatB), 4)
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Inverse Matrix (E^-1)"
String_To_Matrix(MatE.Matrix, "[-2,3,-1; 1,1,1; -4,6,-2]")
DebugMatrix(MatE, 4)
Debug ""
If GaussJordanInverseMatrix(InvE.Matrix, MatE)
DebugMatrix(InvE, 4)
Else
Debug "Singular Matrix : Det(MatE) = " + StrD(DeterminantMatrix(MatE), 4)
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Inverse Matrix (F^-1)"
String_To_Matrix(MatF.Matrix, "[-2,3,-1; 1,1,1; -4, -6,-2]")
DebugMatrix(MatF, 4)
Debug ""
If GaussJordanInverseMatrix(InvF.Matrix, MatF)
DebugMatrix(InvF, 4)
Else
Debug "Singular Matrix : Det(MatF) = " + StrD(DeterminantMatrix(MatF), 4)
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; LU Decompose Matrix [A]"
String_To_Matrix(MatrixA.Matrix, "[25,5,1;64,8,1;144,12,1]")
LUDecomposeMatrix(MatrixA.Matrix, DecomposeL.Matrix, DecomposeU.matrix)
ProductMatrix(DecomposeLU.Matrix, DecomposeL, DecomposeU)
DebugMatrix(MatrixA, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; LU Decompose Matrix [L]"
DebugMatrix(DecomposeL, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; LU Decompose Matrix "
DebugMatrix(DecomposeU, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; LU Decompose Matrix Proof [A] = [L]*"
DebugMatrix(DecomposeLU, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Built Lagrange Polynomial interpolation values from 0.0 to 1.0"
LinearlySpacedVector(U.Matrix, 0.0, 1.0, 40)
DebugMatrix(U, 4)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Waypoint 2D for Lagrange polynom calculation"
String_To_Matrix(PointXY.Matrix, "[1,2; 4,5; 3,3; 5,1; 7,2]")
DebugMatrix(PointXY, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Matrix of Coefficient for Lagrange polynomial"
LagrangePolynomialMatrix(GetMatrixLine(PointXY), Lagrange2D.Matrix, LagrangeInverse2D.Matrix)
DebugMatrix(Lagrange2D, 4)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Matrix of Inverse Coefficient for Lagrange polynom"
DebugMatrix(LagrangeInverse2D, 4)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Compute Lagrange Polynom Equations 2D"
ProductMatrix(Equation2D.Matrix, LagrangeInverse2D, PointXY)
DebugMatrix(Equation2D, 3)
Debug ""
DebugPolynomialMatrix(Equation2D, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Lagrange Polynom Derivation"
DerivatePolynomialMatrix(Derivate2D.Matrix, Equation2D)
DebugMatrix(Derivate2D, 3)
Debug ""
DebugPolynomialMatrix(Derivate2D, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Lagrange Polynom Integration"
String_To_Matrix(Cte2D.Matrix, "[1.0, 2.0]")
IntegratePolynomialMatrix(Integrate2D.Matrix, Derivate2D, Cte2D)
DebugMatrix(Integrate2D, 3)
Debug ""
DebugPolynomialMatrix(Integrate2D, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Lagrange Path 2D From Waypoints 2D"
LagrangePathFromWaypoints(PointXY, U, Path2D.Matrix)
SaveMatrixToCSVFile(0, "Lagrange Path 2D.csv", Path2D)
DebugMatrix(Path2D, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Waypoint 3D for Lagrange polynom calculation"
String_To_Matrix(PointXYZ.Matrix, "[1,2,1; 4,5,7; 3,3,3; 5,1,2; 7,2,2]")
DebugMatrix(PointXYZ, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Lagrange Path 3D From Waypoints 3D"
LagrangePathFromWaypoints(PointXYZ, U, Path3D.Matrix)
SaveMatrixToCSVFile(0, "Lagrange Path 3D.csv", Path3D)
DebugMatrix(Path3D, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Lagrange Path 3D From Waypoints 3D Transposed"
TransposeMatrix(Path3DT.Matrix, Path3D)
DebugMatrix(Path3DT, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Matrix of Coefficient for Lagrange polynom"
LagrangePolynomialMatrix(GetMatrixLine(PointXYZ), Lagrange3D.Matrix, LagrangeInverse3D.Matrix)
DebugMatrix(Lagrange3D, 4)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Matrix of Inverse Coefficient for Lagrange polynom"
DebugMatrix(LagrangeInverse3D, 4)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Compute Lagrange Polynom Equations 3D"
ProductMatrix(Equation3D.Matrix, LagrangeInverse3D, PointXYZ)
DebugMatrix(Equation3D, 3)
Debug ""
DebugPolynomialMatrix(Equation3D, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Lagrange Polynom Derivation"
DerivatePolynomialMatrix(Derivate3D.Matrix, Equation3D)
DebugMatrix(Derivate3D, 3)
Debug ""
DebugPolynomialMatrix(Derivate3D, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Lagrange Polynom Integration"
String_To_Matrix(Cte3D.Matrix, "[1.0, 2.0, 1.0]")
IntegratePolynomialMatrix(Integrate3D.Matrix, Derivate3D, Cte3D)
DebugMatrix(Integrate3D, 3)
Debug ""
DebugPolynomialMatrix(Integrate3D, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; XML file Output/Input"
CreateMatrixXMLFile(0, "Matrix.xml", Path3D)
LoadMatrixXMLFile(1, "Matrix.xml", Path3D_XML.Matrix)
DebugMatrix(Path3D_XML, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Preference file Output/Input"
If CreatePreferences("Matrix pref.pref")
WritePreferenceMatrix("Path3D", Path3D)
ClosePreferences()
EndIf
If OpenPreferences("Matrix pref.pref")
ReadPreferenceMatrix("Path3D", Path3D_PREF.Matrix)
ClosePreferences()
EndIf
DebugMatrix(Path3D_PREF, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Binary file Output/Input"
If CreateFile(0, "Matrix binary.mat")
WriteMatrix(0, Path3D)
CloseFile(0)
EndIf
If ReadFile(1, "Matrix binary.mat")
ReadMatrix(1, Path3D_BIN.Matrix)
CloseFile(1)
EndIf
DebugMatrix(Path3D_BIN, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; DeCasteljau Matrix D0"
DeCasteljauMatrix(5, D_Zero.Matrix, D_One.Matrix)
DebugMatrix(D_Zero, 4)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; DeCasteljau Matrix D1"
DebugMatrix(D_One, 4)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Trefoil Knot Waypoint Matrix"
LinearlySpacedVector(TrefoilKnotU.Matrix, 0.0, 2.0 * #PI, 180)
TrefoilKnotWaypointMatrix(TrefoilKnotU, TrefoilKnotPath.Matrix, 4)
DebugMatrix(TrefoilKnotPath, 4)
SaveMatrixToCSVFile(0, "Trefoil Knot Waypoint 3D.csv", TrefoilKnotPath)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Extract Matrix Minor (2, 3)"
ExtractMatrixMinor(2,3, MinorRandomMatrix.Matrix, RandomMatrix)
DebugMatrix(RandomMatrix)
Debug ""
DebugMatrix(MinorRandomMatrix, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; CatmullRom Spline Path"
String_To_Matrix(CatWaypoint01.Matrix, "[0,0,0; 13,-4,15; 19,20,25; 34,18,15]")
String_To_Matrix(CatWaypoint02.Matrix, "[13,-4,15; 19,20,25; 34,18,15; 30,0,-5]")
String_To_Matrix(CatWaypoint03.Matrix, "[19,20,25; 34,18,15; 30,0,-5; 20,-10,-10]")
LinearlySpacedVector(U2.Matrix, 0.0, 1.0, 20)
CatmullRomPathFromWaypoint(CatWaypoint01, U2, CatmullRomPath01.Matrix)
CatmullRomPathFromWaypoint(CatWaypoint02, U2, CatmullRomPath02.Matrix)
CatmullRomPathFromWaypoint(CatWaypoint03, U2, CatmullRomPath03.Matrix)
CatmullRomPathFusion(CatmullRomPath04.Matrix, CatmullRomPath01, CatmullRomPath02)
CatmullRomPathFusion(CatmullRomPath.Matrix, CatmullRomPath04, CatmullRomPath03)
SaveMatrixToCSVFile(0, "CatmullRomPath 3D.csv", CatmullRomPath)
DebugMatrix(CatmullRomPath, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Catmull-Rom Insert Waypoint"
DebugMatrix(CatWaypoint01, 3)
String_To_Matrix(NewPoint.Matrix, "[30,0,-5]")
Debug ""
CatmullRomInsertWaypoint(CatWaypoint01, NewPoint)
DebugMatrix(CatWaypoint01, 3)
SaveMatrixToCSVFile(0, "CatWaypoint01 3D.csv", CatWaypoint01)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Bezier Path From Control points"
String_To_Matrix(BezierControlPolygon.Matrix, "[0,0,0; 15, 9,4; 19,25,-20; 34,15,-13; 26,-5,2; 20,-10,-9]")
LinearlySpacedVector(U3.Matrix, 0.0, 1.0, 20)
BezierPathFromControlpoints(BezierControlPolygon, U3, BezierPath.Matrix)
DebugMatrix(BezierPath, 3)
SaveMatrixToCSVFile(0, "Bezier Control points.csv", BezierControlPolygon)
SaveMatrixToCSVFile(0, "BezierPath 3D.csv", BezierPath)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Bezier Control polygon from CSV file"
LoadMatrixFromCSVFile(0, "Bezier Control points.csv", BezierControlPolygon2.Matrix)
DebugMatrix(BezierControlPolygon2, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Random Matrix Row Augmented"
AugmentMatrixRow(RowAugmentedRandomMatrix.Matrix, RandomMatrix, RandomMatrix)
DebugAugmentedMatrixRow(RowAugmentedRandomMatrix, GetMatrixRow(RandomMatrix))
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Random Matrix Line Augmented"
AugmentMatrixLine(LineAugmentedRandomMatrix.Matrix, RandomMatrix, RandomMatrix)
DebugAugmentedMatrixLine(LineAugmentedRandomMatrix, GetMatrixLine(RandomMatrix))
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; <<<<< END OF DEMONSTRATION <<<<<"
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Freeing all matrix
ResetMatrix(MatA)
ResetMatrix(MatB)
ResetMatrix(MatC)
ResetMatrix(MatCC)
ResetMatrix(MatD)
ResetMatrix(MatDD)
ResetMatrix(MatBB)
ResetMatrix(MatBS)
ResetMatrix(MatBBT)
ResetMatrix(InvB)
ResetMatrix(MatE)
ResetMatrix(InvE)
ResetMatrix(MatF)
ResetMatrix(InvF)
ResetMatrix(One55)
ResetMatrix(Zero55)
ResetMatrix(Lagrange2D)
ResetMatrix(LagrangeInverse2D)
ResetMatrix(Lagrange3D)
ResetMatrix(LagrangeInverse3D)
ResetMatrix(PointXY)
ResetMatrix(PointXYZ)
ResetMatrix(U)
ResetMatrix(Equation2D)
ResetMatrix(Derivate2D)
ResetMatrix(Cte2D)
ResetMatrix(Integrate2D)
ResetMatrix(Equation3D)
ResetMatrix(Derivate3D)
ResetMatrix(Cte3D)
ResetMatrix(Integrate3D)
ResetMatrix(Path2D)
ResetMatrix(Path3D)
ResetMatrix(Path3DT)
ResetMatrix(Path3D_XML)
ResetMatrix(Path3D_PREF)
ResetMatrix(Path3D_BIN)
ResetMatrix(D_Zero)
ResetMatrix(D_One)
ResetMatrix(RandomMatrix)
ResetMatrix(TrefoilKnotU)
ResetMatrix(TrefoilKnotPath)
ResetMatrix(MinorRandomMatrix)
ResetMatrix(TridiagonalMatrix)
ResetMatrix(TridiagonalMatrixEx)
ResetMatrix(U2)
ResetMatrix(CatWaypoint01)
ResetMatrix(CatWaypoint02)
ResetMatrix(CatWaypoint03)
ResetMatrix(CatmullRomPath01)
ResetMatrix(CatmullRomPath02)
ResetMatrix(CatmullRomPath03)
ResetMatrix(CatmullRomPath04)
ResetMatrix(CatmullRomPath)
ResetMatrix(U3)
ResetMatrix(BezierControlPolygon)
ResetMatrix(BezierPath)
ResetMatrix(BezierControlPolygon2)
ResetMatrix(Diagonal)
ResetMatrix(Line2)
ResetMatrix(Row2)
ResetMatrix(RowAugmentedRandomMatrix)
ResetMatrix(LineAugmentedRandomMatrix)
ResetMatrix(MatrixA)
ResetMatrix(DecomposeU)
ResetMatrix(DecomposeL)
ResetMatrix(DecomposeLU)
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
A+; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : General Maths Matrix Calculation
; File Name : Maths Matrix Calculation - GaussSolver - Testing.pb
; File version: 1.0.0
; Programmation : OK - In progress
; Programmed by : Guimauve
; Date : 04-08-2011
; Last Update : 26-08-2011
; PureBasic code : 4.60
; Plateform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
IncludeFile "Maths Matrix Calculation.pb"
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.1"
String_To_Matrix(EQ_11_4_1.Matrix, "[2,-1;3,5]")
DebugMatrix(EQ_11_4_1, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_1.Matrix, "[11;-16]")
DebugMatrix(CTE_11_4_1, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_1, CTE_11_4_1, SOL_11_4_1.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_1, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_1.Matrix, EQ_11_4_1, SOL_11_4_1)
DebugMatrix(PROOF_11_4_1, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.2"
String_To_Matrix(EQ_11_4_2.Matrix, "[3,-5;4,7]")
DebugMatrix(EQ_11_4_2, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_2.Matrix, "[-36;-7]")
DebugMatrix(CTE_11_4_2, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_2, CTE_11_4_2, SOL_11_4_2.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_2, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_2.Matrix, EQ_11_4_2, SOL_11_4_2)
DebugMatrix(PROOF_11_4_2, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.3"
String_To_Matrix(EQ_11_4_3.Matrix, "[3,-5;6,-10]")
DebugMatrix(EQ_11_4_3, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_3.Matrix, "[7;8]")
DebugMatrix(CTE_11_4_3, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_3, CTE_11_4_3, SOL_11_4_3.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_3, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_3.Matrix, EQ_11_4_3, SOL_11_4_3)
DebugMatrix(PROOF_11_4_3, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.4"
String_To_Matrix(EQ_11_4_4.Matrix, "[1,-3;2,-6]")
DebugMatrix(EQ_11_4_4, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_4.Matrix, "[4;8]")
DebugMatrix(CTE_11_4_4, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_4, CTE_11_4_4, SOL_11_4_4.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_4, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_4.Matrix, EQ_11_4_4, SOL_11_4_4)
DebugMatrix(PROOF_11_4_4, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.5"
String_To_Matrix(EQ_11_4_5.Matrix, "[1,-2,1;2,5,-3;3,4,2]")
DebugMatrix(EQ_11_4_5, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_5.Matrix, "[13;-17;14]")
DebugMatrix(CTE_11_4_5, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_5, CTE_11_4_5, SOL_11_4_5.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_5, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_5.Matrix, EQ_11_4_5, SOL_11_4_5)
DebugMatrix(PROOF_11_4_5, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.6"
String_To_Matrix(EQ_11_4_6.Matrix, "[2,-3,1;3,7,-5;5,-2,4]")
DebugMatrix(EQ_11_4_6, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_6.Matrix, "[-14;-1;-7]")
DebugMatrix(CTE_11_4_6, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_6, CTE_11_4_6, SOL_11_4_6.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_6, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_6.Matrix, EQ_11_4_6, SOL_11_4_6)
DebugMatrix(PROOF_11_4_6, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.7"
String_To_Matrix(EQ_11_4_7.Matrix, "[1,2,-1;2,5,1;4,9,-1]")
DebugMatrix(EQ_11_4_7, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_7.Matrix, "[4;9;17]")
DebugMatrix(CTE_11_4_7, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_7, CTE_11_4_7, SOL_11_4_7.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_7, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_7.Matrix, EQ_11_4_7, SOL_11_4_7)
DebugMatrix(PROOF_11_4_7, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.8"
String_To_Matrix(EQ_11_4_8.Matrix, "[2,1,-3;3,-5,7;4,-11,17]")
DebugMatrix(EQ_11_4_8, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_8.Matrix, "[18;27;36]")
DebugMatrix(CTE_11_4_8, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_8, CTE_11_4_8, SOL_11_4_8.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_8, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_8.Matrix, EQ_11_4_8, SOL_11_4_8)
DebugMatrix(PROOF_11_4_8, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.9"
String_To_Matrix(EQ_11_4_9.Matrix, "[1,-3,2;2,-5,-1;4,-11,3;3,-8,1]")
DebugMatrix(EQ_11_4_9, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_9.Matrix, "[7;16;30;23]")
DebugMatrix(CTE_11_4_9, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_9, CTE_11_4_9, SOL_11_4_9.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_9, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_9.Matrix, EQ_11_4_9, SOL_11_4_9)
DebugMatrix(PROOF_11_4_9, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.10"
String_To_Matrix(EQ_11_4_10.Matrix, "[1,3,-5;3,-4,7;2,1,3;3,4,-2]")
DebugMatrix(EQ_11_4_10, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_10.Matrix, "[-28;69;21;-7]")
DebugMatrix(CTE_11_4_10, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_10, CTE_11_4_10, SOL_11_4_10.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_10, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_10.Matrix, EQ_11_4_10, SOL_11_4_10)
DebugMatrix(PROOF_11_4_10, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.11"
String_To_Matrix(EQ_11_4_11.Matrix, "[2,1,-5;3,4,7;2,-5,4]")
DebugMatrix(EQ_11_4_11, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_11.Matrix, "[-46;7;122]")
DebugMatrix(CTE_11_4_11, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_11, CTE_11_4_11, SOL_11_4_11.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_11, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_11.Matrix, EQ_11_4_11, SOL_11_4_11)
DebugMatrix(PROOF_11_4_11, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.12"
String_To_Matrix(EQ_11_4_12.Matrix, "[4,7,1;5,-3,-4;7,3,2]")
DebugMatrix(EQ_11_4_12, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_12.Matrix, "[10;8;3]")
DebugMatrix(CTE_11_4_12, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_12, CTE_11_4_12, SOL_11_4_12.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_12, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_12.Matrix, EQ_11_4_12, SOL_11_4_12)
DebugMatrix(PROOF_11_4_12, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.13"
String_To_Matrix(EQ_11_4_13.Matrix, "[2,-3,4;2,-2,7]")
DebugMatrix(EQ_11_4_13, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_13.Matrix, "[7;12]")
DebugMatrix(CTE_11_4_13, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_13, CTE_11_4_13, SOL_11_4_13.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_13, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_13.Matrix, EQ_11_4_13, SOL_11_4_13)
DebugMatrix(PROOF_11_4_13, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.14"
String_To_Matrix(EQ_11_4_14.Matrix, "[3,-1,3;-2,1,6;4,5,2]")
DebugMatrix(EQ_11_4_14, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_14.Matrix, "[6;7;3]")
DebugMatrix(CTE_11_4_14, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_14, CTE_11_4_14, SOL_11_4_14.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_14, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_14.Matrix, EQ_11_4_14, SOL_11_4_14)
DebugMatrix(PROOF_11_4_14, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.15"
String_To_Matrix(EQ_11_4_15.Matrix, "[3,-2,7;2,5,-4;5,8,-5]")
DebugMatrix(EQ_11_4_15, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_15.Matrix, "[-22;-87;-158]")
DebugMatrix(CTE_11_4_15, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_15, CTE_11_4_15, SOL_11_4_15.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_15, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_15.Matrix, EQ_11_4_15, SOL_11_4_15)
DebugMatrix(PROOF_11_4_15, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exercice 11.4.16"
String_To_Matrix(EQ_11_4_16.Matrix, "[2,-3,4;3,2,-7;3,4,-2]")
DebugMatrix(EQ_11_4_16, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_11_4_16.Matrix, "[88;2;-2]")
DebugMatrix(CTE_11_4_16, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_11_4_16, CTE_11_4_16, SOL_11_4_16.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_11_4_16, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_11_4_16.Matrix, EQ_11_4_16, SOL_11_4_16)
DebugMatrix(PROOF_11_4_16, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exemple 12.1.1"
String_To_Matrix(EQ_12_1_1.Matrix, "[2,1,-2;3,2,2;5,4,3]")
DebugMatrix(EQ_12_1_1, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_12_1_1.Matrix, "[10,-9;7,10;15,13]")
DebugMatrix(CTE_12_1_1, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
Symbolic.s = GaussSolverMatrixEx(EQ_12_1_1, CTE_12_1_1, SOL_12_1_1.Matrix, 3)
If Symbolic <> "IMPOSSIBLE"
DebugMatrix(SOL_12_1_1, 3)
Debug "Symbolic solution : " + Symbolic
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_12_1_1.Matrix, EQ_12_1_1, SOL_12_1_1)
DebugMatrix(PROOF_12_1_1, 3)
Else
Debug Symbolic
EndIf
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Exemple 12.1.1 (Normal Version)"
String_To_Matrix(EQ_12_1_1_N.Matrix, "[2,1,-2;3,2,2;5,4,3]")
DebugMatrix(EQ_12_1_1_N, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Constants"
String_To_Matrix(CTE_12_1_1_N.Matrix, "[10,-9;7,10;15,13]")
DebugMatrix(CTE_12_1_1_N, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Solution"
If GaussSolverMatrix(EQ_12_1_1_N, CTE_12_1_1_N, SOL_12_1_1_N.Matrix) >= #True
DebugMatrix(SOL_12_1_1_N, 3)
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Proof"
ProductMatrix(PROOF_12_1_1_N.Matrix, EQ_12_1_1_N, SOL_12_1_1_N)
DebugMatrix(PROOF_12_1_1_N, 3)
Else
Debug "Impossible"
EndIf
; <<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< FIN DU FICHIER <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<
Code : Tout sélectionner
Procedure SetMatrixXMLNode(CurrentNode, *MatrixA.Matrix, P_Decimal.b = 6)
If ParentXMLNode(CurrentNode) = #Null
StructNode = CreateXMLNode(CurrentNode,"Matrix")
; SetXMLNodeName(StructNode, "Matrix")
SetXMLAttribute(StructNode, "LineCount", Str(GetMatrixLine(*MatrixA)))
SetXMLAttribute(StructNode, "RowCount", Str(GetMatrixRow(*MatrixA)))
Else
StructNode = CurrentNode
EndIf
For LineID = 0 To GetMatrixLine(*MatrixA) - 1
FieldNode = CreateXMLNode(StructNode,"Line" + Str(LineID + 1))
; SetXMLNodeName(FieldNode, "Line" + Str(LineID + 1))
For RowID = 0 To GetMatrixRow(*MatrixA) - 1
SetXMLAttribute(FieldNode, "L" + Str(LineID + 1) + "_R" + Str(RowID + 1), StrD(PeekMatrixElement(*MatrixA, LineID, RowID), P_Decimal))
Next
Next
EndProcedure