<commit_before>package org.statismo.stk.core
package object geometry {
  // additional information associate to the DIM Type
  sealed trait DimTraits[D <: Dim] {
    def dimensionality: Int
    def zeroVector: Vector[D]
    def zeroPoint : Point[D]
    def createVector(d: Array[Float]): Vector[D]
    def createMatrixNxN(d : Array[Float]) : MatrixNxN[D]
  }

  implicit val oneD = new DimTraits[OneD] {
    def dimensionality = 1
    def zeroVector = Vector1D(0f)
    def zeroPoint = Point1D(0f)
    def createVector(d: Array[Float]) = {
      if (d.size != 1)
        throw new Exception(s"Require array of size 1 to create a Vector1D (got ${d.size}")
      Vector1D(d(0))
    }

    def createMatrixNxN(d: Array[Float]) = {
      if (d.size != 1) {
        throw new Exception(s"Require array of size 1 to create a Matrix1x1 (got ${d.size}")
      }
      Matrix1x1(d)
    }

  }
  implicit val twoD = new DimTraits[TwoD] {
    def dimensionality = 2
    def zeroVector = Vector2D(0f, 0f)
    def zeroPoint = Point2D(0f, 0f)
    def createVector(d: Array[Float]) = {
      if (d.size != 2)
        throw new Exception(s"Require array of size 1 to create a Vector1D (got ${d.size}")
      Vector2D(d(0), d(1))
    }
    def createMatrixNxN(d: Array[Float]) = {
      if (d.size != 4) {
        throw new Exception(s"Require array of size 4 to create a Matrix2x2 (got ${d.size}")
      }
      Matrix2x2(d)
    }

  }
  implicit val threeD = new DimTraits[ThreeD] {
    def dimensionality = 3
    def zeroVector = Vector3D(0f, 0f, 0f)
    def zeroPoint = Point3D(0f, 0f, 0f)
    def createVector(d: Array[Float]) = {
      if (d.size != 3)
        throw new Exception(s"Require array of size 1 to create a Vector3D (got ${d.size}")
      Vector3D(d(0), d(1), d(2))
    }
    def createMatrixNxN(d: Array[Float]) = {
      if (d.size != 9) {
        throw new Exception(s"Require array of size 9 to create a Matrix3x3 (got ${d.size}")
      }
      Matrix3x3(d)
    }

  }
}<commit_msg>added a few more methods to construct points and matrices of arbitrary dimensions<commit_after>package org.statismo.stk.core
package object geometry {
  // additional information associate to the DIM Type
  sealed trait DimTraits[D <: Dim] {
    def dimensionality: Int
    def zeroVector: Vector[D]
    def zeroPoint : Point[D]
    def createVector(d: Array[Float]): Vector[D]
    def createPoint(d: Array[Float]): Point[D]
    def createMatrixNxN(d : Array[Float]) : MatrixNxN[D]
    def zeroMatrix : MatrixNxN[D]
    def eye : MatrixNxN[D]
  }

  implicit val oneD = new DimTraits[OneD] {
    def dimensionality = 1
    def zeroVector = Vector1D(0f)
    def zeroPoint = Point1D(0f)

    def createPoint(d: Array[Float]) = {
     if (d.size != 1)
        throw new Exception(s"Require array of size 1 to create a Point1D (got ${d.size}")
      Point1D(d(0))
    }

    def createVector(d: Array[Float]) = {
      if (d.size != 1)
        throw new Exception(s"Require array of size 1 to create a Vector1D (got ${d.size}")
      Vector1D(d(0))
    }

    def createMatrixNxN(d: Array[Float]) = {
      if (d.size != 1) {
        throw new Exception(s"Require array of size 1 to create a Matrix1x1 (got ${d.size}")
      }
      Matrix1x1(d)
    }

    def zeroMatrix = Matrix1x1.zeros
    def eye = Matrix1x1.eye

  }
  implicit val twoD = new DimTraits[TwoD] {
    def dimensionality = 2
    def zeroVector = Vector2D(0f, 0f)
    def zeroPoint = Point2D(0f, 0f)

    def createVector(d: Array[Float]) = {
      if (d.size != 2)
        throw new Exception(s"Require array of size 1 to create a Vector2D (got ${d.size}")
      Vector2D(d(0), d(1))
    }

    def createPoint(d: Array[Float]) = {
      if (d.size != 2)
        throw new Exception(s"Require array of size 1 to create a Point2D (got ${d.size}")
      Point2D(d(0), d(1))
    }


    def createMatrixNxN(d: Array[Float]) = {
      if (d.size != 4) {
        throw new Exception(s"Require array of size 4 to create a Matrix2x2 (got ${d.size}")
      }
      Matrix2x2(d)
    }

    def zeroMatrix = Matrix2x2.zeros
    def eye = Matrix2x2.eye


  }
  implicit val threeD = new DimTraits[ThreeD] {
    def dimensionality = 3
    def zeroVector = Vector3D(0f, 0f, 0f)
    def zeroPoint = Point3D(0f, 0f, 0f)

    def createVector(d: Array[Float]) = {
      if (d.size != 3)
        throw new Exception(s"Require array of size 1 to create a Vector3D (got ${d.size}")
      Vector3D(d(0), d(1), d(2))
    }

    def createPoint(d: Array[Float]) = {
      if (d.size != 3)
        throw new Exception(s"Require array of size 1 to create a Point3D (got ${d.size}")
      Point3D(d(0), d(1), d(2))
    }


    def createMatrixNxN(d: Array[Float]) = {
      if (d.size != 9) {
        throw new Exception(s"Require array of size 9 to create a Matrix3x3 (got ${d.size}")
      }
      Matrix3x3(d)
    }

    def zeroMatrix = Matrix3x3.zeros
    def eye = Matrix3x3.eye

  }


}
{'fraction_non_alphanumeric': 0.12299247814596463, 'fraction_numerical': 0.029274242732262656, 'mean_word_length': 2.6309963099630997, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3953958', 'n_tokens_mistral': 1815, 'n_tokens_neox': 1757, 'n_words': 511}