     var opt = LM()
     try! opt.optimize(graph: graph, initial: &variables)
 
-    // check results
+    // check number of factor types
     print(variables[TypedID<Pose2, Int>(0)])
     print(variables[TypedID<Pose2, Int>(1)])
     print(variables[TypedID<Pose2, Int>(2)])

@testable import SwiftFusion

/// A factor on two discrete labels evaluation the transition probability
struct DiscreteTransitionFactor {
  /// The number of states.
  let stateCount: Int


    _ transitionMatrix: [Double]
  ) {
    precondition(transitionMatrix.count == stateCount * stateCount)
    self.edges = Tuple2(inputId1, inputId2)
    self.stateCount = stateCount
    self.transitionMatrix = transitionMatrix
  }

  func error(at q: Variables) -> Double {
    let (label1, label2) = (q.head, q.tail.head)
    return -log(transitionMatrix[label2 * stateCount + label1])
  }
}
