--/////////////////////////////////////////////////////////////////////////////
-- Copyright (c) 2000-2025 Ericsson Telecom AB
-- All rights reserved. This program and the accompanying materials
-- are made available under the terms of the Eclipse Public License v2.0
-- which accompanies this distribution, and is available at
-- https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
--
-- Contributors:
--   Balasko, Jeno
--   Raduly, Csaba
--
--/////////////////////////////////////////////////////////////////////////////
ObjectClass DEFINITIONS
  AUTOMATIC TAGS ::=
BEGIN 

IMPORTS /* nothing */ ;


Matrix ::= SEQUENCE OF SEQUENCE OF INTEGER

TwoMat ::= SEQUENCE {
  left  Matrix,
  right Matrix
}


zero Matrix ::=
{{0, 0, 0, 0},
 {0, 0, 0, 0},
 {0, 0, 0, 0},
 {0, 0, 0, 0}}

identity Matrix ::=
{{1, 0, 0, 0},
 {0, 1, 0, 0},
 {0, 0, 1, 0},
 {0, 0, 0, 1}}

pimat Matrix ::=
{{3, 1, 4, 1},
 {5, 9, 2, 6},
 {5, 3, 5, 8},
 {9, 7, 9, 3}}

invpimat Matrix ::= -- the adjugate of pimat
{{-467, -123,   79,   191},
 { 171,   57,  -39,   -67},
 { 326,   76,  -52,  -122},
 {  24,    8,   10,   -18}}

matrixPair TwoMat ::= { left identity, right pimat }


-- object class definition

OPERATION ::= CLASS
{
  &ArgumentType OPTIONAL,
  &ResultType OPTIONAL,
  &Errors ERROR OPTIONAL,
  &Linked OPERATION OPTIONAL,
  &resultReturned BOOLEAN DEFAULT TRUE,
  &operationCode PrintableString UNIQUE
}

ERROR ::= CLASS
{
  &ParameterType OPTIONAL,
  &errorCode INTEGER UNIQUE
}

--



-- object assignment, default syntax


invertMatrix OPERATION ::=
{
  &ArgumentType Matrix,
  &ResultType Matrix,
  &Errors {determinantIsZero},
  &operationCode "invert"
}

determinantIsZero ERROR ::=
{
  &errorCode 1
}

addMatrices OPERATION ::=
{
  &ArgumentType TwoMat,
  &ResultType Matrix,
  &Errors {sizeMismatch},
  &operationCode "add"
}

subtractMatrices OPERATION ::=
{
  &ArgumentType  TwoMat,
  &ResultType    Matrix,
  &Errors        {sizeMismatch},
  &operationCode "subtract"
}

sizeMismatch ERROR ::=
{
  &errorCode 2
}


-- object set

MatrixOperations OPERATION ::=
{
  invertMatrix
  | addMatrices
  | subtractMatrices
  --  | multiplyMatrices
}

-- types

MatOp ::= SEQUENCE {
  op  OPERATION.&operationCode ({MatrixOperations}),
  arg OPERATION.&ArgumentType  ({MatrixOperations} {@op}),
  rez OPERATION.&ResultType    ({MatrixOperations} {@op})
  -- This is not how a real protocol would be put together
}

-- objects

addition MatOp ::= {
  op "add",
  arg twoMat : { left zero, right pimat },
  rez matrix : pimat
}

subtraction MatOp ::= {
  op "subtract",
  arg twoMat : { left identity, right identity },
  rez matrix : zero
}

inversion MatOp ::= {
  op "invert",
  arg matrix : pimat,
  rez matrix : invpimat
}

END
