VerseIsland
Feed Learn Leaderboard Guides Reference Explore Search Docs Verse Library
Sign in
Feed Learn 📖 Codex Leaderboard Guides Reference Explore Search Docs Verse Library
Verse Library › Scene Graph
Browse Verse Library

Library

Devices 634
  • Devices171
  • Triggers & Logic118
  • UI & HUD40
  • Audio39
  • Items & Inventory29
  • Events27
  • Scoring & Objectives25
  • Spawning19
  • Classes & Interfaces18
  • Game Modes17
  • Props & Meshes14
  • Variables & Mutability12
  • Player Management11
  • Modules & Structure10
  • Round Flow8
  • Animation6
  • Concurrency6
  • Functions6
  • Getting Started6
  • Teams & Classes6
  • NPCs & AI5
  • Tutorials5
  • VFX & Particles5
  • Arrays & Maps4
  • Cameras4
  • Debugging4
  • Control Flow3
  • Cinematics2
  • Other2
  • Persistence2
  • Scene Graph2
  • Structs & Enums2
  • Building1
  • Physics1
  • Publishing & Islands1
  • Syntax & Types1
  • Vehicles1
  • Weapons1
Verse Language 257
  • Control Flow35
  • Functions26
  • Arrays & Maps25
  • Classes & Interfaces22
  • Variables & Mutability22
  • Concurrency21
  • Syntax & Types18
  • Modules & Structure12
  • Debugging8
  • Devices8
  • Events7
  • Player Management6
  • Structs & Enums6
  • Triggers & Logic6
  • Game Modes5
  • Failure & Options4
  • Scene Graph4
  • UI & HUD4
  • Getting Started3
  • Round Flow3
  • Spawning3
  • VFX & Particles3
  • Reference2
  • Animation1
  • Best Practices1
  • Other1
  • Props & Meshes1
Materials/VFX 154
  • Triggers & Logic27
  • UI & HUD17
  • Devices16
  • VFX & Particles14
  • Props & Meshes11
  • Scoring & Objectives9
  • Game Modes7
  • Items & Inventory7
  • Functions6
  • Arrays & Maps5
  • Animation3
  • Cinematics3
  • Classes & Interfaces3
  • Control Flow3
  • Events3
  • Modules & Structure3
  • Round Flow3
  • Spawning3
  • Getting Started2
  • Scene Graph2
  • Variables & Mutability2
  • Concurrency1
  • Persistence1
  • Player Management1
  • Structs & Enums1
  • Syntax & Types1
General 153
  • Devices22
  • Events20
  • Triggers & Logic20
  • Classes & Interfaces10
  • Variables & Mutability8
  • Round Flow6
  • Scoring & Objectives6
  • UI & HUD6
  • Functions5
  • Player Management5
  • Game Modes4
  • Getting Started4
  • Props & Meshes4
  • Control Flow3
  • Syntax & Types3
  • VFX & Particles3
  • Arrays & Maps2
  • Best Practices2
  • NPCs & AI2
  • Other2
  • Physics2
  • Scene Graph2
  • Spawning2
  • Structs & Enums2
  • Tutorials2
  • Building1
  • Cameras1
  • Cinematics1
  • Failure & Options1
  • Items & Inventory1
  • Teams & Classes1
Player 133
  • Player Management22
  • Teams & Classes19
  • Classes & Interfaces12
  • Devices11
  • Events9
  • Persistence7
  • Triggers & Logic7
  • Arrays & Maps6
  • Functions4
  • Game Modes4
  • Items & Inventory4
  • Round Flow4
  • Debugging3
  • Getting Started3
  • Modules & Structure3
  • Concurrency2
  • Control Flow2
  • Scoring & Objectives2
  • Spawning2
  • Structs & Enums2
  • Physics1
  • Props & Meshes1
  • UI & HUD1
  • Variables & Mutability1
  • Weapons1
Building & Props 131
  • Variables & Mutability15
  • Props & Meshes14
  • Triggers & Logic12
  • Classes & Interfaces10
  • Devices10
  • UI & HUD10
  • Events7
  • Teams & Classes7
  • Animation5
  • Building5
  • Functions5
  • VFX & Particles5
  • Structs & Enums4
  • Control Flow3
  • Game Modes3
  • Items & Inventory3
  • Round Flow3
  • Scene Graph3
  • Arrays & Maps2
  • Concurrency2
  • Reference2
  • Modules & Structure1
NPCs & AI 76
  • NPCs & AI35
  • Spawning7
  • Animation5
  • Variables & Mutability5
  • Classes & Interfaces3
  • Debugging3
  • UI & HUD3
  • Audio2
  • Concurrency2
  • Game Modes2
  • Props & Meshes2
  • Triggers & Logic2
  • Devices1
  • Functions1
  • Getting Started1
  • Reference1
  • VFX & Particles1
Spawning 73
  • Spawning31
  • Events7
  • Concurrency6
  • Player Management6
  • Vehicles5
  • Props & Meshes4
  • Devices3
  • Scene Graph3
  • Items & Inventory2
  • Teams & Classes2
  • Control Flow1
  • Publishing & Islands1
  • Reference1
  • Scoring & Objectives1
Cinematics 71
  • Cameras19
  • Cinematics15
  • Devices11
  • Audio5
  • Animation4
  • Triggers & Logic4
  • Functions2
  • Game Modes2
  • UI & HUD2
  • Classes & Interfaces1
  • Concurrency1
  • Control Flow1
  • Items & Inventory1
  • Modules & Structure1
  • Scene Graph1
  • Templates1
UI 57
  • UI & HUD35
  • Devices5
  • Scoring & Objectives4
  • Classes & Interfaces3
  • Round Flow2
  • Scene Graph2
  • Arrays & Maps1
  • Props & Meshes1
  • Structs & Enums1
  • Templates1
  • Triggers & Logic1
  • Variables & Mutability1
Scene Graph 40
  • Scene Graph9
  • Items & Inventory8
  • Classes & Interfaces3
  • Events3
  • Props & Meshes3
  • Functions2
  • Arrays & Maps1
  • Building1
  • Control Flow1
  • Debugging1
  • Modules & Structure1
  • Player Management1
  • Reference1
  • Structs & Enums1
  • Syntax & Types1
  • Triggers & Logic1
  • UI & HUD1
  • VFX & Particles1
Vehicles 38
  • Spawning11
  • Devices7
  • Vehicles7
  • Props & Meshes4
  • Functions2
  • Game Modes2
  • Failure & Options1
  • Items & Inventory1
  • Reference1
  • Teams & Classes1
  • Tutorials1
Tutorials 37
  • Game Modes6
  • Triggers & Logic5
  • Classes & Interfaces4
  • Events4
  • Props & Meshes3
  • Building2
  • Devices2
  • Items & Inventory2
  • Scoring & Objectives2
  • Animation1
  • Arrays & Maps1
  • Cameras1
  • Concurrency1
  • Physics1
  • Player Management1
  • Structs & Enums1
Weapons 30
  • Game Modes6
  • Weapons6
  • Devices5
  • Items & Inventory3
  • Scoring & Objectives3
  • Spawning2
  • Teams & Classes2
  • Best Practices1
  • Functions1
  • Triggers & Logic1
Items 28
  • Items & Inventory23
  • Devices2
  • Triggers & Logic2
  • Spawning1
Assets 20
  • Modules & Structure6
  • Arrays & Maps3
  • Functions3
  • Scene Graph2
  • Best Practices1
  • Devices1
  • Events1
  • Failure & Options1
  • Physics1
  • Variables & Mutability1
Animation 19
  • Animation10
  • Variables & Mutability4
  • Devices1
  • Player Management1
  • Props & Meshes1
  • Scene Graph1
  • Syntax & Types1
Release Notes 17
  • Classes & Interfaces5
  • Modules & Structure3
  • Concurrency2
  • Control Flow2
  • Variables & Mutability2
  • Debugging1
  • Devices1
  • Items & Inventory1
Input & Controls 16
  • Functions4
  • UI & HUD3
  • Control Flow2
  • Animation1
  • Arrays & Maps1
  • Cinematics1
  • Debugging1
  • Devices1
  • Events1
  • Items & Inventory1
Publishing 8
  • Control Flow5
  • Arrays & Maps1
  • Devices1
  • Syntax & Types1
Audio 7
  • Audio5
  • UI & HUD2
Landscape 7
  • Other4
  • VFX & Particles2
  • Scene Graph1
Persistence 6
  • Structs & Enums2
  • Items & Inventory1
  • Persistence1
  • Publishing & Islands1
  • Variables & Mutability1
Physics 5
  • Functions2
  • Classes & Interfaces1
  • Devices1
  • Syntax & Types1
Creator Economy 3
  • Publishing & Islands2
  • Modules & Structure1
Discovery 3
  • Devices1
  • NPCs & AI1
  • Structs & Enums1
Editor & Project 3
  • Other1
  • Props & Meshes1
  • Tutorials1

Matrix Math Utilities

Module — 2 files
These files compile together (same module folder).
file_1.verse
# Module for matrices
Matrices<public> := module:

	using { Arrays }
	using { Comparisons }
	using { /UnrealEngine.com/Temporary }

	# Float Matrices
	Matrix<public> := class<concrete>:
		Rows<public>:int=0
		Cols<public>:int=0
		Rep<public>:[][]float=array{}

	<# MATRIX CONSTRUCTION #>

	# Construct matrix
	ConstructMatrix<public><constructor>(InRep:[][]float)<decides><transacts>:=Matrix:
		let:
			var InRows:int = InRep.Length
			var InCols:int = if (ColOne:=InRep[0].Length, ColOne > 0):
				ColOne
			else:
				0
		block:
			for (Row:=0..InRows-1):
				InRep[Row].Length = InCols
		Rows:=InRows
		Cols:=InCols
		Rep:=InRep

	# Construct matrix from integers
	ConstructMatrixFromInts<public><constructor>(InRep:[][]int)<decides><transacts>:=Matrix:
		let:
			var InRows:int = InRep.Length
			var RepTemp:[][]float = array{}
			var InCols:int = if (ColOne:=InRep[0].Length, ColOne > 0):
				ColOne
			else:
				0
		block:
			for (Row:=0..InRows-1):
				InRep[Row].Length = InCols
			for (Row:=0..InRows-1):
				if:
					TempRow := for(Col:=0..InCols-1):
						1.0*InRep[Row][Col]
					set RepTemp += array{TempRow}
		Rows:=InRows
		Cols:=InCols
		Rep:=RepTemp

	# Create copy of matrix
	(InMatrix:Matrix).Copy<public>()<transacts>:Matrix=
		Matrix:
			Rows:=InMatrix.Rows
			Cols:=InMatrix.Cols
			Rep:=InMatrix.Rep

	# Identity matrix
	Identity<public>(Size:int)<transacts>:Matrix=
		var RepTemp:[][]float = array{}
		for (Row:=0..Size-1):
			TempRow:[]float = for(Col:=0..Size-1):
				if (Row = Col):
					1.0
				else:
					0.0
			set RepTemp += array{TempRow}
		Matrix:
			Rows:=Size
			Cols:=Size
			Rep:=RepTemp

	# Zero matrix
	Zeros<public>(InRows:int, InCols:int)<transacts>:Matrix=
		var RepTemp:[][]float = array{}
		for (Row:=0..InRows-1):
			TempRow:[]float = for(Col:=0..InCols-1):
				0.0
			set RepTemp += array{TempRow}
		Matrix:
			Rows:=InRows
			Cols:=InCols
			Rep:=RepTemp

	# Square zero matrix
	Zeros<public>(Size:int)<transacts>:Matrix=
		Zeros(Size, Size)

	# Matrix with ones on main diagonal
	MainDiagonalOnes<public>(InRows:int, InCols:int)<transacts>:Matrix=
		var RepTemp:[][]float = array{}
		for (Row:=0..InRows-1):
			TempRow:[]float = for(Col:=0..InCols-1):
				if (Row = Col):
					1.0
				else:
					0.0
			set RepTemp += array{TempRow}
		Matrix:
			Rows:=InRows
			Cols:=InCols
			Rep:=RepTemp

	<# MATRIX OPERATIONS #>

	# Summary: Multiply two float matrices
	# Complexity: Theta(n^3)
	operator'*'<public>(InMatrixOne:Matrix, InMatrixTwo:Matrix)<transacts><decides>:Matrix=
		InMatrixOne.Cols = InMatrixTwo.Rows
		var ResultMatrix:Matrix = Zeros(InMatrixOne.Rows,InMatrixTwo.Cols)
		for (Row:=0..InMatrixOne.Rows-1):
			for (Col:=0..InMatrixTwo.Cols-1):
				var RowColEntry:float = 0.0
				for (MatchDimension:=0..InMatrixOne.Cols-1):
					set RowColEntry += (InMatrixOne.Rep[Row][MatchDimension] * InMatrixTwo.Rep[MatchDimension][Col])
				ResultMatrixTemp := ResultMatrix.SetElementAtIndex[(Row,Col), RowColEntry]
				set ResultMatrix = ResultMatrixTemp
		ResultMatrix

	# Summary: Add two float matrices
	# Complexity: Theta(n^2)
	operator'+'<public>(InMatrixOne:Matrix, InMatrixTwo:Matrix)<transacts><decides>:Matrix=
		InMatrixOne.Cols = InMatrixTwo.Cols
		InMatrixOne.Rows = InMatrixTwo.Rows
		var TempRep:[][]float = array{}
		for (Row:=0..InMatrixOne.Rows-1):
			if:
				TempRow := for(Col:=0..InMatrixOne.Cols-1):
					InMatrixOne.Rep[Row][Col] + InMatrixTwo.Rep[Row][Col]
				set TempRep += array{TempRow}
		ConstructMatrix[TempRep]

	# Summary: Subtract two float matrices
	# Complexity: Theta(n^2)
	operator'-'<public>(InMatrixOne:Matrix, InMatrixTwo:Matrix)<transacts><decides>:Matrix=
		InMatrixOne.Cols = InMatrixTwo.Cols
		InMatrixOne.Rows = InMatrixTwo.Rows
		var TempRep:[][]float = array{}
		for (Row:=0..InMatrixOne.Rows-1):
			if:
				TempRow := for(Col:=0..InMatrixOne.Cols-1):
					InMatrixOne.Rep[Row][Col] - InMatrixTwo.Rep[Row][Col]
				set TempRep += array{TempRow}
		ConstructMatrix[TempRep]

	# Summary: Transpose a matrix
	# 		Converts a n x m matrix into an m x n matrix by reflecting over main diagonal
	# Complexity: Theta(n^2)
	(InMatrix:Matrix).Transpose<public>()<decides><transacts>:Matrix=
		var NewRep:[][]float = array{}
		for (Col:=0..InMatrix.Cols-1):
			if:
				TempRow := for(Row:=0..InMatrix.Rows-1):
					InMatrix.Rep[Row][Col]
				set NewRep += array{TempRow}
		ConstructMatrix[NewRep]

	# Summary: Invert a matrix
	#		Find a matrix B such that AB = I, if one exists
	# Complexity: Theta(n^3)
	(InMatrix:Matrix).Inverse<public>()<decides><transacts>:Matrix=
		var Columns:[][]float = array{}
		InMatrix.Rows = InMatrix.Cols
		Size:int = InMatrix.Rows
		LUPDecomposition := LUP[InMatrix]
		LowerTriangular:Matrix = LUPDecomposition(0)
		UpperTriangular:Matrix = LUPDecomposition(1)
		PermutationArray:[]int = LUPDecomposition(2)
		for (Row:=0..Size-1):
			ResultantVector:[]float = for (Col:=0..Size-1):
				if (Row = Col):
					1.0
				else:
					0.0
			LinearSystemSolution := LUPSolve(LowerTriangular, UpperTriangular, PermutationArray, ResultantVector)
			set Columns += array{LinearSystemSolution}
		OutMatrix:Matrix = ConstructMatrix[Columns]
		OutMatrix.Transpose[]

	# Summary: Determinant of a matrix
	# Complexity: Theta(n^3)
	(InMatrix:Matrix).Determinant<public>()<decides><transacts>:float=
		if (LUPDecomposition := LUP[InMatrix]):
			UpperTriangular:=LUPDecomposition(1)
			Diagonal:[]float = for (i:=0..UpperTriangular.Rows-1):
				UpperTriangular.GetElementAtIndex[i,i]
			var AccumulatedProduct:float = 1.0
			for (Element:Diagonal):
				set AccumulatedProduct *= Element
			AccumulatedProduct
		else:
			0.0

	# Summary: Set the value of the matrix at the specified tuple index
	# Theta(n^2)
	(InMatrix:Matrix).SetElementAtIndex<public>(Index:tuple(int,int), Element:float)<decides><transacts>:Matrix=
		var TempRep:[][]float = array{}
		var Success:logic = true
		for (Row:=0..InMatrix.Rows-1):
			TempRow:[]float = for(Col:=0..InMatrix.Cols-1):
				if (Row = Index(0), Col = Index(1)):
					Element
				else if (InEntry := InMatrix.Rep[Row][Col]):
					InEntry
				else:
					set Success = false
					0.0
			set TempRep += array{TempRow}
		Success?
		ConstructMatrix[TempRep]

	# Complexity: Theta(n^2)
	(InMatrix:Matrix).GetElementAtIndex<public>(Row:int, Col:int)<decides><transacts>:float=
		InMatrix.Rep[Row][Col]

	<# MATRIX ALGORITHMS #>

	# Solve a system of linear equations of the form Ax = b for the vector x
	SolveLinearSystem<public>(A:Matrix, b:[]float)<decides><transacts>:[]float =
		LUPDecomposition := LUP[A]
		LowerTriangular:Matrix = LUPDecomposition(0)
		UpperTriangular:Matrix = LUPDecomposition(1)
		PermutationArray:[]int = LUPDecomposition(2)
		LUPSolve(LowerTriangular, UpperTriangular, PermutationArray, b)

	# Internal solution for linear systems of equations
	LUPSolve<internal>(L:Matrix, U:Matrix, p:[]int, b:[]float)<transacts>:[]float=
		Rows:int=L.Rows
		var IntermediateVector:[]float = array{}
		var SolutionVector:[]float = for(Row:=0..Rows-1):
			0.0
		for (Row:=0..Rows-1, PermutationElement:=b[p[Row]]):
			var PartialSum:float = 0.0
			for:
				Col:=0..Row-1
				LRowCol:=L.Rep[Row][Col]
				IntermediateVectorTemp:=IntermediateVector[Col]
			do:
				set PartialSum += LRowCol * IntermediateVectorTemp
			set IntermediateVector += array{PermutationElement - 1.0 * PartialSum}
		for:
			Row:=0..Rows-1
			ReverseRow:=Rows-1-Row
			IntermediateVectorTemp:=IntermediateVector[ReverseRow]
			URowRow:=U.Rep[ReverseRow][ReverseRow]
		do:
			var PartialSum:float = 0.0
			for:
				Col:=ReverseRow+1..Rows-1
				URowCol:=U.Rep[ReverseRow][Col]
				SolutionVectorTemp:=SolutionVector[Col]
			do:
				set PartialSum += URowCol * SolutionVectorTemp
			if (set SolutionVector[ReverseRow] = (IntermediateVectorTemp - PartialSum) / URowRow):
		SolutionVector

	# Summary: Obtain the LU-Decomposition of the matrix A
	# Fails: A is singular
	# Complexity: Theta(n^3)
	LU<public>(A:Matrix)<decides><transacts>:tuple(Matrix,Matrix)=
		Size:int=A.Rows
		var ATemp:Matrix=A.Copy()
		var L:Matrix=Identity(Size)
		var U:Matrix=Zeros(Size,Size)
		for (k:=0..Size-1):
			UTempMatrix:=U.SetElementAtIndex[(k,k), ATemp.Rep[k][k]]
			set U = UTempMatrix
			for (i:=k+1..Size-1):
				LTempMatrix:=L.SetElementAtIndex[(i,k), ATemp.Rep[i][k] / ATemp.Rep[k][k]]
				set L = LTempMatrix
				UInnerTempMatrix:=U.SetElementAtIndex[(k,i), ATemp.Rep[k][i]]
				set U = UInnerTempMatrix
			for (i:=k+1..Size-1):
				for (j:=k+1..Size-1):
					Aij:=ATemp.Rep[i][j]
					AInnerTemp:=ATemp.SetElementAtIndex[(i,j), Aij - (L.Rep[i][k] * U.Rep[k][j])]
					set ATemp = AInnerTemp
		(L,U)

	# Summary: Obtain the LUP-Decomposition of the matrix A such that PA=LU
	#		where:
	#			L - lower triangular
	#			U - upper triangular
	#			P - permutation matrix
	# Fails: A is singular
	# Complexity: Theta(n^3)
	LUP<public>(A:Matrix)<decides><transacts>:tuple(Matrix,Matrix,[]int)=
		Size:int=A.Rows
		var ATemp:Matrix=A.Copy()
		var PermutationArray:[]int = for(i:=0..Size-1):
			i
		for (k:=0..Size-1):
			var PVal:float = 0.0
			var Kprime:int = 0
			for (i:=k..Size-1):
				if (Aik:=Abs(ATemp.Rep[i][k]), Aik > PVal):
					set PVal = Aik
					set Kprime = i
			# If PVal = 0, then PVal is singular and the procedure fails
			PVal <> 0.0
			SwappedArray:=PermutationArray.Swap[k,Kprime]
			set PermutationArray = SwappedArray
			for (i:=0..Size-1):
				FirstTemp:=ATemp.Rep[k][i]
				SecondTemp:=ATemp.Rep[Kprime][i]
				FirstTempMat:=ATemp.SetElementAtIndex[(Kprime,i), FirstTemp]
				SecondTempMat:=FirstTempMat.SetElementAtIndex[(k,i), SecondTemp]
				set ATemp = SecondTempMat
			for (i:=k+1..Size-1):
				ThirdTempMat:=ATemp.SetElementAtIndex[(i,k), ATemp.Rep[i][k] / ATemp.Rep[k][k]]
				set ATemp = ThirdTempMat
				for (j:=k+1..Size-1):
					FourthTempMat:=ATemp.SetElementAtIndex[(i,j), ATemp.Rep[i][j] - (ATemp.Rep[i][k] * ATemp.Rep[k][j])]
					set ATemp = FourthTempMat
		L:Matrix=ATemp.ExtractLowerTriangle[]
		U:Matrix=ATemp.ExtractUpperTriangle[]
		(L, U, PermutationArray)

	# Extract the upper triangular matrix from the LUP algorithm implementation
	(InMatrix:Matrix).ExtractUpperTriangle<internal>()<decides><transacts>:Matrix=
		var OutMatrix:Matrix=Zeros(InMatrix.Rows,InMatrix.Cols)
		for (i:=0..InMatrix.Rows-1, j:=0..InMatrix.Cols-1, i <= j):
			Temp:=OutMatrix.SetElementAtIndex[(i,j), InMatrix.Rep[i][j]]
			set OutMatrix = Temp
		OutMatrix

	# Extract the lower triangular matrix from the LUP algorithm implementation
	(InMatrix:Matrix).ExtractLowerTriangle<internal>()<decides><transacts>:Matrix=
		var OutMatrix:Matrix=Identity(InMatrix.Rows)
		for (i:=0..InMatrix.Rows-1, j:=0..InMatrix.Cols-1, i > j):
			Temp:=OutMatrix.SetElementAtIndex[(i,j), InMatrix.Rep[i][j]]
			set OutMatrix = Temp
		OutMatrix

	# Convert a permutation array into a permutation matrix
	(InArray:[]int).ToPermutationMatrix<public>()<decides><transacts>:Matrix=
		Size:int = InArray.Length
		SortedArray:=SortBy(InArray, IntegerLessThan)
		RangeArray:=for (i:=0..Size-1). 1.0 * i
		for (i:=0..Size-1):
			1.0 * SortedArray[i] = RangeArray[i]
		var OutMatrix:Matrix=Zeros(Size)
		for (i:=0..Size-1, j:=InArray[i]):
			MatrixTemp:=OutMatrix.SetElementAtIndex[(i,j), 1.0]
			set OutMatrix = MatrixTemp
		OutMatrix

	<# CODE UTILITIES #>

	# String rep of matrix
	ToString<public>(InMatrix:Matrix)<transacts>:[]char=
		var ReturnString:[]char = "\n"
		for (Row:=0..InMatrix.Rows-1):
			set ReturnString += "\t"
			for (Col:=0..InMatrix.Cols-1, Entry:=InMatrix.Rep[Row][Col]):
				set ReturnString += "{Entry} "
			set ReturnString += "\n"
		ReturnString

	# String rep of float array
	ArrayToString<public>(InArray:[]float)<transacts>:[]char=
		var ReturnString:[]char = "\{"
		for (Entry:InArray):
			set ReturnString += " {Entry} "
		set ReturnString += "\}\n"
		ReturnString

	# String rep of float array
	IntArrayToString<public>(InArray:[]int)<transacts>:[]char=
		var ReturnString:[]char = "\{"
		for (Entry:InArray):
			set ReturnString += " {Entry} "
		set ReturnString += "\}\n"
		ReturnString

Arrays<public> := module:

	# Array utility to swap the elements contained in indices I and J
	(Array:[]t where t:type).Swap<public>(FirstIndex:int, SecondIndex:int)<decides><transacts>:[]t =
		ArrayTemp := Array.ReplaceElement[FirstIndex, Array[SecondIndex]]
		return ArrayTemp.ReplaceElement[SecondIndex, Array[FirstIndex]]

Comparisons<public> := module:

	IntegerLessThan<public>(A:int, B:int)<decides><computes>:void =
		A < B

	IntegerEquivalent<public>(A:int, B:int)<decides><computes>:void =
		A = B
matrix_test.verse
using { /UnrealEngine.com/Temporary/Diagnostics }

log_matrix_test := class(log_channel):

# A project-wide "Logger" to print messages from functions that are not in a class with a log.
MatrixLog<public>(Message:[]char, ?Level:log_level = log_level.Normal)<transacts>:void=
    Logger := log{Channel := log_graph_test}
    Logger.Print(Message, ?Level := Level)

using { /Fortnite.com/Devices }
using { Matrices }

matrix_test := class(creative_device):

	OnBegin<override>()<suspends>:void=

		I4:Matrix = Identity(4)
		Z3:Matrix = Zeros(3,3)
		C:Matrix = Matrix:
			Rows:=3
			Cols:=3
			Rep:=array:
				array{1.0,2.0,3.0}
				array{4.0,5.0,6.0}
				array{7.0,8.0,9.0}

		var D:Matrix = Matrix{}
		if (DTemp:=Z3 + C):
			set D = DTemp

		var E:Matrix = Matrix{}
		if (ETemp:=ConstructMatrix[
			array:
				array{2.0,4.0,6.0}
				array{0.0,8.0,10.0}
				array{0.0,0.0,12.0}
		]):
			set E = ETemp

		var F:Matrix = Matrix{}
		if (FTemp:=D + E):
			set F = FTemp

		var H:Matrix = Matrix{}
		var J:Matrix = Matrix{}
		if (HTemp:=ConstructMatrix[
			array:
				array{2.0,4.0,6.0,7.0,15.0}
				array{0.0,8.0,10.0,11.0,17.0}
				array{0.0,0.0,12.0,13.0,19.0}
		]):
			set H = HTemp
			if (JTemp:=H.Transpose[]):
				set J = JTemp

		MatrixLog("I4: {I4}")
		MatrixLog("Z3: {Z3}")
		MatrixLog("C: {C}")
		MatrixLog("E: {E}")
		MatrixLog("Z3 + C: {D}")
		MatrixLog("C + E: {F}")
		MatrixLog("H: {H}")
		MatrixLog("H^T: {J}")

		var X:Matrix = Matrix{}
		if:
			XTemp:=ConstructMatrix[
				array:
					array{2.0, 	3.0, 	1.0, 	5.0}
					array{6.0, 	13.0, 	5.0, 	19.0}
					array{2.0, 	19.0, 	10.0, 	23.0}
					array{4.0, 	10.0, 	11.0, 	31.0}
			]
		then:
			set X = XTemp
			if (LUDecomposition:=LU[X]):
				MatrixLog("X: {X}")
				MatrixLog("L: {LUDecomposition(0)}")
				MatrixLog("U: {LUDecomposition(1)}")

		var Y:Matrix = Matrix{}
		if:
			YTemp:=ConstructMatrix[
				array:
					array{2.0, 	0.0, 	2.0, 	0.6}
					array{3.0, 	3.0, 	4.0, 	-2.0}
					array{5.0, 	5.0, 	4.0, 	2.0}
					array{-1.0, -2.0, 	3.4, 	-1.0}
			]
		then:
			set Y = YTemp
			if (LUPDecomposition:=LUP[Y]):
				MatrixLog("Y: {Y}")
				MatrixLog("L: {LUPDecomposition(0)}")
				MatrixLog("U: {LUPDecomposition(1)}")
				if (Pt:=LUPDecomposition(2).ToPermutationMatrix[]):
					MatrixLog("P: {Pt}")
				if (YInv:=Y.Inverse[]):
					MatrixLog("YInverse: {YInv}")
					if (I:=Y * YInv):
						MatrixLog("Y*YInverse: {I}")
Sign in to download module

Copy-paste each file above is always free.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in
    📄
    Source
    @let
    Epic Games Community
    @let

    Created by a member of the Epic Games community. Rights remain with the original author, under Epic's community content terms. Terms ↗

    View original Sources & licensing
    Request removal
    Last updated Jun 23, 2026
    Verse module (2 files)
    Build failed · 2 errors

    Download the full module (zip) from the code panel above.

    Keep exploring
    More in Verse Language · 58 of 106
    Prev
    fortnite subscribable utils
    Next
    array utils
    Related topics
    • Fortnite Float To Int Cast And Operators Verse Language
    • spatialmath Verse Language
    • creativeanimation Devices
    • Fortnite Heaps And Heapsort Verse Language
    • spatialmath Verse Language

    Related

    Open in graph →

    Related topics

    • Fortnite Float To Int Cast And Operators
    • spatialmath
    • creativeanimation
    • Fortnite Heaps And Heapsort
    • spatialmath
    VerseIsland · an archipelago of Verse & UEFN knowledge
    🗺️ Island atlas Learn Guides History About & Press Sources & Licensing Status

    Not affiliated with Epic Games. Fortnite, UEFN, Unreal Engine, and Verse are trademarks of Epic Games, Inc. Content is attributed to its source — see Sources & Licensing.

    🦜

    Scout · your island guide

    The Isle of Verse