Initializing Multi dimentionnal array

BlitzMax Forums/BlitzMax Programming/Initializing Multi dimentionnal array

Mathieu A(Posted 2005) [#1]
Hi, I have a type Matrix 3x3:

Type Matrix3

Field Matrix : Float [3, 3]

End Type

And I want to initialize a constant array Identity :

[1, 0, 0
0, 1, 0
0, 0, 1]

How can I do that?
Thanks


klepto2(Posted 2005) [#2]
I hope I have you understand right, If not just ignore my Post.

Const Matrix:String = "100010001"


Type Matrix3

Field Matrix : Float[3, 3]

Function Init:Matrix3()
	Local MDim:Int  = 3
	Local D1:Int = 0
	Local D2:Int = 0
	Local M:Matrix3 = New Matrix3
		For Local _I = 0 To Matrix.length - 1
			
			If D1 > 2 Then 
				D1 = 0
				D2:+1
			EndIf
			
			M.Matrix[D1,D2] = Int(Mid(Matrix,_I+1,1))
			D1:+1
		Next
		
	Return M	
End Function


End Type

M:Matrix3 = Matrix3.Init()

For x = 0 To 2
	For y = 0 To 2

	Print M.Matrix[x,y]
	
	Next
Next



levent(Posted 2005) [#3]
This works too, but don't ask me why;)
Local Matrix[][] = [[1,1,1],[2,2,2],[3,3,3]]

For x = 0 To 2
	For y = 0 To 2

	Print Matrix[x][y]
	
	Next
	Print
Next




Mathieu A(Posted 2005) [#4]
Thanks Levent. But I'd like to know how to configure easily an multi dimensionnal array like this one :

Field Matrix : Float [3, 3]

Maybe I must use a loop to initialize it.


tonyg(Posted 2005) [#5]
You can't auto-initialise it...
multidim