# Define custom Operator for custom Resource?

4.2

### Question

Hello,

for my project it would be useful to have a tensor, (a tensor in math is simply a vector3 where each component is a matrix, or a matrix whose components are vectors3)

Right now I just use [base(),base(),base], but sometimes my data comes in as array[array] and not array[base], so I thought I’d just define my own resource

my code so far:

class Tensor3:

## Die erste Matrix’s des Tensors

var x : Basis = Basis(Vector3i(1,0,0),Vector3i(),Vector3i())

## Die zweite Matrix’s des Tensors

var y : Basis = Basis(Vector3i(),Vector3i(0,1,0),Vector3i())

## Die dritte Matrix’s des Tensors

var z : Basis = Basis(Vector3i(),Vector3i(),Vector3i(0,0,1))

## Konstruktor (init-Methode)

func _init( _x : Basis = x, _y : Basis = y, _z : Basis = z ):
self.x = _x
self.y = _y
self.z = _z

## Determinante des Tensors

func determinant() → float:
var pro : Array =
pro += [ self.x.x.xself.y.y.yself.z.z.z]
pro += [- self.x.x.yself.y.y.zself.z.z.x]
pro += [- self.x.x.zself.y.y.xself.z.z.y]
pro += [- self.x.y.xself.y.z.yself.z.x.z]
pro += [ self.x.y.yself.y.z.xself.z.x.z]
pro += [ self.x.y.zself.y.z.zself.z.x.x]
pro += [ self.x.z.xself.y.x.yself.z.y.z]
pro += [- self.x.z.yself.y.x.zself.z.y.x]
pro += [ self.x.z.zself.y.x.xself.z.y.y]

``````  var sum : float

for i in pro.size():
sum += pro[i]

return sum
``````

My question now is, how do I define operators?
and how do I make sure that the constructor is listed as a constructor in the automatically generated help page?

I think this is supported in C# but not GDScript. Here’s a proposal to add this to GDScript.