Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/18/17 14:22:46 (8 years ago)
Author:
gkronber
Message:

#2650 adapted formatters to handle factor symbols

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r14399 r14764  
    7272        strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root));
    7373        return strBuilder.ToString();
    74       } catch (NotImplementedException ex) {
     74      } catch(NotImplementedException ex) {
    7575        return ex.Message + Environment.NewLine + ex.StackTrace;
    7676      }
     
    8585      FormatBegin(node, strBuilder);
    8686
    87       if (node.SubtreeCount > 0) {
     87      if(node.SubtreeCount > 0) {
    8888        strBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    8989      }
    9090      int i = 1;
    91       foreach (var subTree in node.Subtrees.Skip(1)) {
     91      foreach(var subTree in node.Subtrees.Skip(1)) {
    9292        FormatSep(node, strBuilder, i);
    9393        // format the whole subtree
     
    102102
    103103    private void FormatBegin(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    104       if (node.Symbol is Addition) {
     104      if(node.Symbol is Addition) {
    105105        strBuilder.Append(@" \left( ");
    106       } else if (node.Symbol is Subtraction) {
    107         if (node.SubtreeCount == 1) {
     106      } else if(node.Symbol is Subtraction) {
     107        if(node.SubtreeCount == 1) {
    108108          strBuilder.Append(@"- \left( ");
    109109        } else {
    110110          strBuilder.Append(@" \left( ");
    111111        }
    112       } else if (node.Symbol is Multiplication) {
    113       } else if (node.Symbol is Division) {
    114         if (node.SubtreeCount == 1) {
     112      } else if(node.Symbol is Multiplication) {
     113      } else if(node.Symbol is Division) {
     114        if(node.SubtreeCount == 1) {
    115115          strBuilder.Append(@" \cfrac{1}{");
    116116        } else {
    117117          strBuilder.Append(@" \cfrac{ ");
    118118        }
    119       } else if (node.Symbol is Average) {
     119      } else if(node.Symbol is Average) {
    120120        // skip output of (1/1) if only one subtree
    121         if (node.SubtreeCount > 1) {
     121        if(node.SubtreeCount > 1) {
    122122          strBuilder.Append(@" \cfrac{1}{" + node.SubtreeCount + @"}");
    123123        }
    124124        strBuilder.Append(@" \left( ");
    125       } else if (node.Symbol is Logarithm) {
     125      } else if(node.Symbol is Logarithm) {
    126126        strBuilder.Append(@"\log \left( ");
    127       } else if (node.Symbol is Exponential) {
     127      } else if(node.Symbol is Exponential) {
    128128        strBuilder.Append(@"\exp \left( ");
    129       } else if (node.Symbol is Square) {
     129      } else if(node.Symbol is Square) {
    130130        strBuilder.Append(@"\left(");
    131       } else if (node.Symbol is SquareRoot) {
     131      } else if(node.Symbol is SquareRoot) {
    132132        strBuilder.Append(@"\sqrt{");
    133       } else if (node.Symbol is Sine) {
     133      } else if(node.Symbol is Sine) {
    134134        strBuilder.Append(@"\sin \left( ");
    135       } else if (node.Symbol is Cosine) {
     135      } else if(node.Symbol is Cosine) {
    136136        strBuilder.Append(@"\cos \left( ");
    137       } else if (node.Symbol is Tangent) {
     137      } else if(node.Symbol is Tangent) {
    138138        strBuilder.Append(@"\tan \left( ");
    139       } else if (node.Symbol is AiryA) {
     139      } else if(node.Symbol is AiryA) {
    140140        strBuilder.Append(@"\operatorname{airy}_a \left( ");
    141       } else if (node.Symbol is AiryB) {
     141      } else if(node.Symbol is AiryB) {
    142142        strBuilder.Append(@"\operatorname{airy}_b \left( ");
    143       } else if (node.Symbol is Bessel) {
     143      } else if(node.Symbol is Bessel) {
    144144        strBuilder.Append(@"\operatorname{bessel}_1 \left( ");
    145       } else if (node.Symbol is CosineIntegral) {
     145      } else if(node.Symbol is CosineIntegral) {
    146146        strBuilder.Append(@"\operatorname{cosInt} \left( ");
    147       } else if (node.Symbol is Dawson) {
     147      } else if(node.Symbol is Dawson) {
    148148        strBuilder.Append(@"\operatorname{dawson} \left( ");
    149       } else if (node.Symbol is Erf) {
     149      } else if(node.Symbol is Erf) {
    150150        strBuilder.Append(@"\operatorname{erf} \left( ");
    151       } else if (node.Symbol is ExponentialIntegralEi) {
     151      } else if(node.Symbol is ExponentialIntegralEi) {
    152152        strBuilder.Append(@"\operatorname{expInt}_i \left( ");
    153       } else if (node.Symbol is FresnelCosineIntegral) {
     153      } else if(node.Symbol is FresnelCosineIntegral) {
    154154        strBuilder.Append(@"\operatorname{fresnel}_\operatorname{cosInt} \left( ");
    155       } else if (node.Symbol is FresnelSineIntegral) {
     155      } else if(node.Symbol is FresnelSineIntegral) {
    156156        strBuilder.Append(@"\operatorname{fresnel}_\operatorname{sinInt} \left( ");
    157       } else if (node.Symbol is Gamma) {
     157      } else if(node.Symbol is Gamma) {
    158158        strBuilder.Append(@"\Gamma \left( ");
    159       } else if (node.Symbol is HyperbolicCosineIntegral) {
     159      } else if(node.Symbol is HyperbolicCosineIntegral) {
    160160        strBuilder.Append(@"\operatorname{hypCosInt} \left( ");
    161       } else if (node.Symbol is HyperbolicSineIntegral) {
     161      } else if(node.Symbol is HyperbolicSineIntegral) {
    162162        strBuilder.Append(@"\operatorname{hypSinInt} \left( ");
    163       } else if (node.Symbol is Norm) {
     163      } else if(node.Symbol is Norm) {
    164164        strBuilder.Append(@"\operatorname{norm} \left( ");
    165       } else if (node.Symbol is Psi) {
     165      } else if(node.Symbol is Psi) {
    166166        strBuilder.Append(@"\operatorname{digamma} \left( ");
    167       } else if (node.Symbol is SineIntegral) {
     167      } else if(node.Symbol is SineIntegral) {
    168168        strBuilder.Append(@"\operatorname{sinInt} \left( ");
    169       } else if (node.Symbol is GreaterThan) {
     169      } else if(node.Symbol is GreaterThan) {
    170170        strBuilder.Append(@"  \left( ");
    171       } else if (node.Symbol is LessThan) {
     171      } else if(node.Symbol is LessThan) {
    172172        strBuilder.Append(@"  \left( ");
    173       } else if (node.Symbol is And) {
     173      } else if(node.Symbol is And) {
    174174        strBuilder.Append(@"  \left( \left( ");
    175       } else if (node.Symbol is Or) {
     175      } else if(node.Symbol is Or) {
    176176        strBuilder.Append(@"   \left( \left( ");
    177       } else if (node.Symbol is Not) {
     177      } else if(node.Symbol is Not) {
    178178        strBuilder.Append(@" \neg \left( ");
    179       } else if (node.Symbol is IfThenElse) {
     179      } else if(node.Symbol is IfThenElse) {
    180180        strBuilder.Append(@" \operatorname{if}  \left( ");
    181       } else if (node.Symbol is Constant) {
     181      } else if(node.Symbol is Constant) {
    182182        var constName = "c_{" + constIndex + "}";
    183183        constIndex++;
    184184        var constNode = node as ConstantTreeNode;
    185         if (constNode.Value.IsAlmost(1.0)) {
     185        if(constNode.Value.IsAlmost(1.0)) {
    186186          strBuilder.Append("1 ");
    187187        } else {
     
    190190        }
    191191
    192       } else if (node.Symbol is FactorVariable) {
     192      } else if(node.Symbol is FactorVariable) {
    193193        var factorNode = node as FactorVariableTreeNode;
    194194        var constName = "c_{" + constIndex + "}";
    195195        strBuilder.Append(constName + " ");
    196         foreach (var e in factorNode.Symbol.GetVariableValues(factorNode.VariableName)
     196        foreach(var e in factorNode.Symbol.GetVariableValues(factorNode.VariableName)
    197197          .Zip(factorNode.Weights, Tuple.Create)) {
    198198          constants.Add(new KeyValuePair<string, double>("c_{" + constIndex + ", " + EscapeLatexString(factorNode.VariableName) + "=" + EscapeLatexString(e.Item1) + "}", e.Item2));
    199199        }
    200200        constIndex++;
    201       } else if (node.Symbol is BinaryFactorVariable) {
     201      } else if(node.Symbol is BinaryFactorVariable) {
    202202        var binFactorNode = node as BinaryFactorVariableTreeNode;
    203         if (!binFactorNode.Weight.IsAlmost((1.0))) {
     203        if(!binFactorNode.Weight.IsAlmost((1.0))) {
    204204          var constName = "c_{" + constIndex + "}";
    205205          strBuilder.Append(constName + "  \\cdot");
     
    207207          constIndex++;
    208208        }
    209         strBuilder.Append(EscapeLatexString(binFactorNode.VariableName));
     209        strBuilder.Append("(" + EscapeLatexString(binFactorNode.VariableName));
    210210        strBuilder.Append(LagToString(currentLag));
    211         strBuilder.Append(" = " + EscapeLatexString(binFactorNode.VariableValue));
    212       } else if (node.Symbol is LaggedVariable) {
     211        strBuilder.Append(" = " + EscapeLatexString(binFactorNode.VariableValue) + " )");
     212      } else if(node.Symbol is LaggedVariable) {
    213213        var laggedVarNode = node as LaggedVariableTreeNode;
    214         if (!laggedVarNode.Weight.IsAlmost(1.0)) {
     214        if(!laggedVarNode.Weight.IsAlmost(1.0)) {
    215215          var constName = "c_{" + constIndex + "}";
    216216          strBuilder.Append(constName + "  \\cdot");
     
    221221        strBuilder.Append(LagToString(currentLag + laggedVarNode.Lag));
    222222
    223       } else if (node.Symbol is Variable) {
     223      } else if(node.Symbol is Variable) {
    224224        var varNode = node as VariableTreeNode;
    225         if (!varNode.Weight.IsAlmost((1.0))) {
     225        if(!varNode.Weight.IsAlmost((1.0))) {
    226226          var constName = "c_{" + constIndex + "}";
    227227          strBuilder.Append(constName + "  \\cdot");
     
    231231        strBuilder.Append(EscapeLatexString(varNode.VariableName));
    232232        strBuilder.Append(LagToString(currentLag));
    233       } else if (node.Symbol is ProgramRootSymbol) {
     233      } else if(node.Symbol is ProgramRootSymbol) {
    234234        strBuilder
    235235          .AppendLine("\\begin{align*}")
    236236          .AppendLine("\\nonumber");
    237       } else if (node.Symbol is Defun) {
     237      } else if(node.Symbol is Defun) {
    238238        var defunNode = node as DefunTreeNode;
    239239        strBuilder.Append(defunNode.FunctionName + " & = ");
    240       } else if (node.Symbol is InvokeFunction) {
     240      } else if(node.Symbol is InvokeFunction) {
    241241        var invokeNode = node as InvokeFunctionTreeNode;
    242242        strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( ");
    243       } else if (node.Symbol is StartSymbol) {
     243      } else if(node.Symbol is StartSymbol) {
    244244        FormatStartSymbol(strBuilder);
    245       } else if (node.Symbol is Argument) {
     245      } else if(node.Symbol is Argument) {
    246246        var argSym = node.Symbol as Argument;
    247247        strBuilder.Append(" ARG+" + argSym.ArgumentIndex + " ");
    248       } else if (node.Symbol is Derivative) {
     248      } else if(node.Symbol is Derivative) {
    249249        strBuilder.Append(@" \cfrac{d \left( ");
    250       } else if (node.Symbol is TimeLag) {
     250      } else if(node.Symbol is TimeLag) {
    251251        var laggedNode = node as ILaggedTreeNode;
    252252        currentLag += laggedNode.Lag;
    253       } else if (node.Symbol is Power) {
     253      } else if(node.Symbol is Power) {
    254254        strBuilder.Append(@" \left( ");
    255       } else if (node.Symbol is Root) {
     255      } else if(node.Symbol is Root) {
    256256        strBuilder.Append(@" \left( ");
    257       } else if (node.Symbol is Integral) {
     257      } else if(node.Symbol is Integral) {
    258258        // actually a new variable for t is needed in all subtrees (TODO)
    259259        var laggedTreeNode = node as ILaggedTreeNode;
    260260        strBuilder.Append(@"\sum_{t=" + (laggedTreeNode.Lag + currentLag) + @"}^0 \left( ");
    261       } else if (node.Symbol is VariableCondition) {
     261      } else if(node.Symbol is VariableCondition) {
    262262        var conditionTreeNode = node as VariableConditionTreeNode;
    263263        var constName = "c_{" + constants.Count + "}";
     
    276276
    277277    private void FormatSep(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, int step) {
    278       if (node.Symbol is Addition) {
     278      if(node.Symbol is Addition) {
    279279        strBuilder.Append(" + ");
    280       } else if (node.Symbol is Subtraction) {
     280      } else if(node.Symbol is Subtraction) {
    281281        strBuilder.Append(" - ");
    282       } else if (node.Symbol is Multiplication) {
     282      } else if(node.Symbol is Multiplication) {
    283283        strBuilder.Append(@" \cdot ");
    284       } else if (node.Symbol is Division) {
    285         if (step + 1 == node.SubtreeCount)
     284      } else if(node.Symbol is Division) {
     285        if(step + 1 == node.SubtreeCount)
    286286          strBuilder.Append(@"}{");
    287287        else
    288288          strBuilder.Append(@" }{ \cfrac{ ");
    289       } else if (node.Symbol is Average) {
     289      } else if(node.Symbol is Average) {
    290290        strBuilder.Append(@" + ");
    291       } else if (node.Symbol is Logarithm) {
    292         throw new InvalidOperationException();
    293       } else if (node.Symbol is Exponential) {
    294         throw new InvalidOperationException();
    295       } else if (node.Symbol is Square) {
    296         throw new InvalidOperationException();
    297       } else if (node.Symbol is SquareRoot) {
    298         throw new InvalidOperationException();
    299       } else if (node.Symbol is Sine) {
    300         throw new InvalidOperationException();
    301       } else if (node.Symbol is Cosine) {
    302         throw new InvalidOperationException();
    303       } else if (node.Symbol is Tangent) {
    304         throw new InvalidOperationException();
    305       } else if (node.Symbol is AiryA) {
    306         throw new InvalidOperationException();
    307       } else if (node.Symbol is AiryB) {
    308         throw new InvalidOperationException();
    309       } else if (node.Symbol is Bessel) {
    310         throw new InvalidOperationException();
    311       } else if (node.Symbol is CosineIntegral) {
    312         throw new InvalidOperationException();
    313       } else if (node.Symbol is Dawson) {
    314         throw new InvalidOperationException();
    315       } else if (node.Symbol is Erf) {
    316         throw new InvalidOperationException();
    317       } else if (node.Symbol is ExponentialIntegralEi) {
    318         throw new InvalidOperationException();
    319       } else if (node.Symbol is FresnelCosineIntegral) {
    320         throw new InvalidOperationException();
    321       } else if (node.Symbol is FresnelSineIntegral) {
    322         throw new InvalidOperationException();
    323       } else if (node.Symbol is Gamma) {
    324         throw new InvalidOperationException();
    325       } else if (node.Symbol is HyperbolicCosineIntegral) {
    326         throw new InvalidOperationException();
    327       } else if (node.Symbol is HyperbolicSineIntegral) {
    328         throw new InvalidOperationException();
    329       } else if (node.Symbol is Norm) {
    330         throw new InvalidOperationException();
    331       } else if (node.Symbol is Psi) {
    332         throw new InvalidOperationException();
    333       } else if (node.Symbol is SineIntegral) {
    334         throw new InvalidOperationException();
    335       } else if (node.Symbol is GreaterThan) {
     291      } else if(node.Symbol is Logarithm) {
     292        throw new InvalidOperationException();
     293      } else if(node.Symbol is Exponential) {
     294        throw new InvalidOperationException();
     295      } else if(node.Symbol is Square) {
     296        throw new InvalidOperationException();
     297      } else if(node.Symbol is SquareRoot) {
     298        throw new InvalidOperationException();
     299      } else if(node.Symbol is Sine) {
     300        throw new InvalidOperationException();
     301      } else if(node.Symbol is Cosine) {
     302        throw new InvalidOperationException();
     303      } else if(node.Symbol is Tangent) {
     304        throw new InvalidOperationException();
     305      } else if(node.Symbol is AiryA) {
     306        throw new InvalidOperationException();
     307      } else if(node.Symbol is AiryB) {
     308        throw new InvalidOperationException();
     309      } else if(node.Symbol is Bessel) {
     310        throw new InvalidOperationException();
     311      } else if(node.Symbol is CosineIntegral) {
     312        throw new InvalidOperationException();
     313      } else if(node.Symbol is Dawson) {
     314        throw new InvalidOperationException();
     315      } else if(node.Symbol is Erf) {
     316        throw new InvalidOperationException();
     317      } else if(node.Symbol is ExponentialIntegralEi) {
     318        throw new InvalidOperationException();
     319      } else if(node.Symbol is FresnelCosineIntegral) {
     320        throw new InvalidOperationException();
     321      } else if(node.Symbol is FresnelSineIntegral) {
     322        throw new InvalidOperationException();
     323      } else if(node.Symbol is Gamma) {
     324        throw new InvalidOperationException();
     325      } else if(node.Symbol is HyperbolicCosineIntegral) {
     326        throw new InvalidOperationException();
     327      } else if(node.Symbol is HyperbolicSineIntegral) {
     328        throw new InvalidOperationException();
     329      } else if(node.Symbol is Norm) {
     330        throw new InvalidOperationException();
     331      } else if(node.Symbol is Psi) {
     332        throw new InvalidOperationException();
     333      } else if(node.Symbol is SineIntegral) {
     334        throw new InvalidOperationException();
     335      } else if(node.Symbol is GreaterThan) {
    336336        strBuilder.Append(@" > ");
    337       } else if (node.Symbol is LessThan) {
     337      } else if(node.Symbol is LessThan) {
    338338        strBuilder.Append(@" < ");
    339       } else if (node.Symbol is And) {
     339      } else if(node.Symbol is And) {
    340340        strBuilder.Append(@" > 0  \right) \land \left(");
    341       } else if (node.Symbol is Or) {
     341      } else if(node.Symbol is Or) {
    342342        strBuilder.Append(@" > 0  \right) \lor \left(");
    343       } else if (node.Symbol is Not) {
    344         throw new InvalidOperationException();
    345       } else if (node.Symbol is IfThenElse) {
     343      } else if(node.Symbol is Not) {
     344        throw new InvalidOperationException();
     345      } else if(node.Symbol is IfThenElse) {
    346346        strBuilder.Append(@" , ");
    347       } else if (node.Symbol is ProgramRootSymbol) {
     347      } else if(node.Symbol is ProgramRootSymbol) {
    348348        strBuilder.Append(@"\\" + Environment.NewLine);
    349       } else if (node.Symbol is Defun) {
    350       } else if (node.Symbol is InvokeFunction) {
     349      } else if(node.Symbol is Defun) {
     350      } else if(node.Symbol is InvokeFunction) {
    351351        strBuilder.Append(" , ");
    352       } else if (node.Symbol is StartSymbol) {
     352      } else if(node.Symbol is StartSymbol) {
    353353        strBuilder.Append(@"\\" + Environment.NewLine);
    354354        FormatStartSymbol(strBuilder);
    355       } else if (node.Symbol is Power) {
     355      } else if(node.Symbol is Power) {
    356356        strBuilder.Append(@"\right) ^ { \operatorname{round} \left(");
    357       } else if (node.Symbol is Root) {
     357      } else if(node.Symbol is Root) {
    358358        strBuilder.Append(@"\right) ^ {  \cfrac{1}{ \operatorname{round} \left(");
    359       } else if (node.Symbol is VariableCondition) {
     359      } else if(node.Symbol is VariableCondition) {
    360360        var conditionTreeNode = node as VariableConditionTreeNode;
    361361        var const1Name = "c_{" + constants.Count + "}";
     
    374374
    375375    private void FormatEnd(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    376       if (node.Symbol is Addition) {
    377         strBuilder.Append(@" \right) ");
    378       } else if (node.Symbol is Subtraction) {
    379         strBuilder.Append(@" \right) ");
    380       } else if (node.Symbol is Multiplication) {
    381       } else if (node.Symbol is Division) {
     376      if(node.Symbol is Addition) {
     377        strBuilder.Append(@" \right) ");
     378      } else if(node.Symbol is Subtraction) {
     379        strBuilder.Append(@" \right) ");
     380      } else if(node.Symbol is Multiplication) {
     381      } else if(node.Symbol is Division) {
    382382        strBuilder.Append(" } ");
    383         for (int i = 2; i < node.SubtreeCount; i++)
     383        for(int i = 2; i < node.SubtreeCount; i++)
    384384          strBuilder.Append(" } ");
    385       } else if (node.Symbol is Average) {
    386         strBuilder.Append(@" \right) ");
    387       } else if (node.Symbol is Logarithm) {
    388         strBuilder.Append(@" \right) ");
    389       } else if (node.Symbol is Exponential) {
    390         strBuilder.Append(@" \right) ");
    391       } else if (node.Symbol is Square) {
     385      } else if(node.Symbol is Average) {
     386        strBuilder.Append(@" \right) ");
     387      } else if(node.Symbol is Logarithm) {
     388        strBuilder.Append(@" \right) ");
     389      } else if(node.Symbol is Exponential) {
     390        strBuilder.Append(@" \right) ");
     391      } else if(node.Symbol is Square) {
    392392        strBuilder.Append(@"\right)^2");
    393       } else if (node.Symbol is SquareRoot) {
     393      } else if(node.Symbol is SquareRoot) {
    394394        strBuilder.Append(@"}");
    395       } else if (node.Symbol is Sine) {
    396         strBuilder.Append(@" \right) ");
    397       } else if (node.Symbol is Cosine) {
    398         strBuilder.Append(@" \right) ");
    399       } else if (node.Symbol is Tangent) {
    400         strBuilder.Append(@" \right) ");
    401       } else if (node.Symbol is AiryA) {
    402         strBuilder.Append(@" \right) ");
    403       } else if (node.Symbol is AiryB) {
    404         strBuilder.Append(@" \right) ");
    405       } else if (node.Symbol is Bessel) {
    406         strBuilder.Append(@" \right) ");
    407       } else if (node.Symbol is CosineIntegral) {
    408         strBuilder.Append(@" \right) ");
    409       } else if (node.Symbol is Dawson) {
    410         strBuilder.Append(@" \right) ");
    411       } else if (node.Symbol is Erf) {
    412         strBuilder.Append(@" \right) ");
    413       } else if (node.Symbol is ExponentialIntegralEi) {
    414         strBuilder.Append(@" \right) ");
    415       } else if (node.Symbol is FresnelCosineIntegral) {
    416         strBuilder.Append(@" \right) ");
    417       } else if (node.Symbol is FresnelSineIntegral) {
    418         strBuilder.Append(@" \right) ");
    419       } else if (node.Symbol is Gamma) {
    420         strBuilder.Append(@" \right) ");
    421       } else if (node.Symbol is HyperbolicCosineIntegral) {
    422         strBuilder.Append(@" \right) ");
    423       } else if (node.Symbol is HyperbolicSineIntegral) {
    424         strBuilder.Append(@" \right) ");
    425       } else if (node.Symbol is Norm) {
    426         strBuilder.Append(@" \right) ");
    427       } else if (node.Symbol is Psi) {
    428         strBuilder.Append(@" \right) ");
    429       } else if (node.Symbol is SineIntegral) {
    430         strBuilder.Append(@" \right) ");
    431       } else if (node.Symbol is GreaterThan) {
    432         strBuilder.Append(@" \right) ");
    433       } else if (node.Symbol is LessThan) {
    434         strBuilder.Append(@" \right) ");
    435       } else if (node.Symbol is And) {
     395      } else if(node.Symbol is Sine) {
     396        strBuilder.Append(@" \right) ");
     397      } else if(node.Symbol is Cosine) {
     398        strBuilder.Append(@" \right) ");
     399      } else if(node.Symbol is Tangent) {
     400        strBuilder.Append(@" \right) ");
     401      } else if(node.Symbol is AiryA) {
     402        strBuilder.Append(@" \right) ");
     403      } else if(node.Symbol is AiryB) {
     404        strBuilder.Append(@" \right) ");
     405      } else if(node.Symbol is Bessel) {
     406        strBuilder.Append(@" \right) ");
     407      } else if(node.Symbol is CosineIntegral) {
     408        strBuilder.Append(@" \right) ");
     409      } else if(node.Symbol is Dawson) {
     410        strBuilder.Append(@" \right) ");
     411      } else if(node.Symbol is Erf) {
     412        strBuilder.Append(@" \right) ");
     413      } else if(node.Symbol is ExponentialIntegralEi) {
     414        strBuilder.Append(@" \right) ");
     415      } else if(node.Symbol is FresnelCosineIntegral) {
     416        strBuilder.Append(@" \right) ");
     417      } else if(node.Symbol is FresnelSineIntegral) {
     418        strBuilder.Append(@" \right) ");
     419      } else if(node.Symbol is Gamma) {
     420        strBuilder.Append(@" \right) ");
     421      } else if(node.Symbol is HyperbolicCosineIntegral) {
     422        strBuilder.Append(@" \right) ");
     423      } else if(node.Symbol is HyperbolicSineIntegral) {
     424        strBuilder.Append(@" \right) ");
     425      } else if(node.Symbol is Norm) {
     426        strBuilder.Append(@" \right) ");
     427      } else if(node.Symbol is Psi) {
     428        strBuilder.Append(@" \right) ");
     429      } else if(node.Symbol is SineIntegral) {
     430        strBuilder.Append(@" \right) ");
     431      } else if(node.Symbol is GreaterThan) {
     432        strBuilder.Append(@" \right) ");
     433      } else if(node.Symbol is LessThan) {
     434        strBuilder.Append(@" \right) ");
     435      } else if(node.Symbol is And) {
    436436        strBuilder.Append(@" > 0 \right) \right) ");
    437       } else if (node.Symbol is Or) {
     437      } else if(node.Symbol is Or) {
    438438        strBuilder.Append(@" > 0 \right) \right) ");
    439       } else if (node.Symbol is Not) {
    440         strBuilder.Append(@" \right) ");
    441       } else if (node.Symbol is IfThenElse) {
    442         strBuilder.Append(@" \right) ");
    443       } else if (node.Symbol is Constant) {
    444       } else if (node.Symbol is LaggedVariable) {
    445       } else if (node.Symbol is Variable) {
    446       } else if (node.Symbol is FactorVariable) {
    447       } else if (node.Symbol is BinaryFactorVariable) {
    448       } else if (node.Symbol is ProgramRootSymbol) {
     439      } else if(node.Symbol is Not) {
     440        strBuilder.Append(@" \right) ");
     441      } else if(node.Symbol is IfThenElse) {
     442        strBuilder.Append(@" \right) ");
     443      } else if(node.Symbol is Constant) {
     444      } else if(node.Symbol is LaggedVariable) {
     445      } else if(node.Symbol is Variable) {
     446      } else if(node.Symbol is FactorVariable) {
     447      } else if(node.Symbol is BinaryFactorVariable) {
     448      } else if(node.Symbol is ProgramRootSymbol) {
    449449        strBuilder
    450450          .AppendLine("\\end{align*}")
     
    452452          .AppendLine("\\nonumber");
    453453        // output all constant values
    454         if (constants.Count > 0) {
    455           foreach (var constant in constants) {
     454        if(constants.Count > 0) {
     455          foreach(var constant in constants) {
    456456            // replace "." with ".&" to align decimal points
    457457            var constStr = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "{0:G5}", constant.Value);
    458             if (!constStr.Contains(".")) constStr = constStr + ".0";
     458            if(!constStr.Contains(".")) constStr = constStr + ".0";
    459459            constStr = constStr.Replace(".", "&.");  // fix problem in rendering of aligned expressions
    460460            strBuilder.Append(constant.Key + "& = & " + constStr);
     
    463463        }
    464464        strBuilder.AppendLine("\\end{align*}");
    465       } else if (node.Symbol is Defun) {
    466       } else if (node.Symbol is InvokeFunction) {
    467         strBuilder.Append(@" \right) ");
    468       } else if (node.Symbol is StartSymbol) {
    469       } else if (node.Symbol is Argument) {
    470       } else if (node.Symbol is Derivative) {
     465      } else if(node.Symbol is Defun) {
     466      } else if(node.Symbol is InvokeFunction) {
     467        strBuilder.Append(@" \right) ");
     468      } else if(node.Symbol is StartSymbol) {
     469      } else if(node.Symbol is Argument) {
     470      } else if(node.Symbol is Derivative) {
    471471        strBuilder.Append(@" \right) }{dt} ");
    472       } else if (node.Symbol is TimeLag) {
     472      } else if(node.Symbol is TimeLag) {
    473473        var laggedNode = node as ILaggedTreeNode;
    474474        currentLag -= laggedNode.Lag;
    475       } else if (node.Symbol is Power) {
     475      } else if(node.Symbol is Power) {
    476476        strBuilder.Append(@" \right) } ");
    477       } else if (node.Symbol is Root) {
     477      } else if(node.Symbol is Root) {
    478478        strBuilder.Append(@" \right) } } ");
    479       } else if (node.Symbol is Integral) {
    480         strBuilder.Append(@" \right) ");
    481       } else if (node.Symbol is VariableCondition) {
     479      } else if(node.Symbol is Integral) {
     480        strBuilder.Append(@" \right) ");
     481      } else if(node.Symbol is VariableCondition) {
    482482        strBuilder.Append(@"\right) ");
    483483      } else {
     
    488488    private void FormatStartSymbol(StringBuilder strBuilder) {
    489489      strBuilder.Append(targetVariable ?? "target_" + (targetCount++));
    490       if (containsTimeSeriesSymbol)
     490      if(containsTimeSeriesSymbol)
    491491        strBuilder.Append("(t)");
    492492      strBuilder.Append(" & = ");
     
    494494
    495495    private string LagToString(int lag) {
    496       if (lag < 0) {
     496      if(lag < 0) {
    497497        return "(t" + lag + ")";
    498       } else if (lag > 0) {
     498      } else if(lag > 0) {
    499499        return "(t+" + lag + ")";
    500500      } else return "";
Note: See TracChangeset for help on using the changeset viewer.