public static GaNumMapUnilinearTree ToTreeMap(this Dictionary <int, GaNumMultivector> basisBladeMaps, int domainVSpaceDim, int targetVSpaceDim) { var resultMap = GaNumMapUnilinearTree.Create(domainVSpaceDim, targetVSpaceDim); foreach (var term in basisBladeMaps.Where(p => !p.Value.IsNullOrZero())) { resultMap.SetBasisBladeMap(term.Key, term.Value); } return(resultMap); }
public static DotGraph ToGraphViz(this GaNumMapUnilinearTree unilinearMap, bool showFullGraph = false, bool showLeafValues = false) { var dotGraph = DotGraph.Directed("Graph"); dotGraph.AddBinaryTree(unilinearMap.BasisBladesMapTree, showFullGraph); if (!showLeafValues) { return(dotGraph); } foreach (var leafPair in unilinearMap.BasisBladesMapTree.LeafValuePairs) { var dotHtmlTable = DotUtils.Table(); dotHtmlTable.SetBorder(0); dotHtmlTable.SetCellBorder(1); var dotHtmlRow = dotHtmlTable.AddRow(); var mv = leafPair.Value; foreach (var term in mv.Terms) { var columnTable = DotUtils.Table(); columnTable.SetBorder(0); columnTable.SetCellBorder(0); columnTable.AddRow( term.Key.PatternToString(mv.VSpaceDimension).ToHtmlString() ); columnTable.AddRow(term.Value.ToString("G")); dotHtmlRow.AddCell(columnTable); } var parentNodeName = leafPair.Key.PatternToString(unilinearMap.DomainVSpaceDimension); var node = dotGraph.AddNode("coef" + parentNodeName); node.SetLabel(dotHtmlTable); node.SetShape(DotNodeShape.Note); node.SetStyle(DotNodeStyle.Solid); node.SetColor(DotColor.Rgb(Color.Black)); node.SetFontColor(DotColor.Rgb(Color.Black)); var dotEdge = node.AddEdgeFrom(parentNodeName); dotEdge.SetArrowHead(DotArrowType.Inv); dotEdge.SetArrowTail(DotArrowType.Inv); dotEdge.SetStyle(DotEdgeStyle.Solid); dotEdge.SetColor(DotColor.Rgb(Color.Black)); dotEdge.SetFontColor(DotColor.Rgb(Color.Black)); } return(dotGraph); }
public static GaNumMapUnilinearTree ToTreeMap(this IGaNumMapUnilinear linearMap) { var resultMap = GaNumMapUnilinearTree.Create( linearMap.DomainVSpaceDimension, linearMap.TargetVSpaceDimension ); foreach (var basisBladeMap in linearMap.BasisBladeMaps()) { resultMap.SetBasisBladeMap(basisBladeMap.Item1, basisBladeMap.Item2); } return(resultMap); }
public static GaNumMapUnilinearTree ToTreeMap(this Matrix linearMapMatrix) { Debug.Assert(linearMapMatrix.RowCount.IsValidGaSpaceDimension() && linearMapMatrix.ColumnCount.IsValidGaSpaceDimension()); var resultMap = GaNumMapUnilinearTree.Create( linearMapMatrix.ColumnCount.ToVSpaceDimension(), linearMapMatrix.RowCount.ToVSpaceDimension() ); for (var id = 0; id < linearMapMatrix.ColumnCount; id++) { var mv = GaNumMultivector.CreateFromColumn(linearMapMatrix, id); if (!mv.IsNullOrZero()) { resultMap.SetBasisBladeMap(id, mv); } } return(resultMap); }