[poincare] Add a debug method to print prime factorization

Change-Id: I7dfa25bd67cdc1c5388f718aa7363c4dd52c0b66
This commit is contained in:
Émilie Feral
2017-09-26 15:57:28 +02:00
parent 5f6e668d81
commit 2a9f044887
2 changed files with 17 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
#include <poincare/global_context.h>
#include <poincare/expression.h>
#include <poincare/symbol.h>
#include <poincare/integer.h>
#include <iostream>
namespace Poincare {
@@ -67,4 +68,18 @@ void print_expression(const Expression * e, int indentationLevel) {
}
}
void print_prime_factorization(Integer * outputFactors, Integer * outputCoefficients, int outputLength) {
GlobalContext context;
for (int index = 0; index < outputLength; index++) {
if (outputCoefficients[index].isEqualTo(Integer(0))) {
break;
}
std::cout << outputFactors[index].approximate<double>(context);
std::cout << "^";
std::cout << outputCoefficients[index].approximate<double>(context);
std::cout << "+";
}
std::cout <<" "<< std::endl;
}
}

View File

@@ -2,10 +2,12 @@
#define POICARE_EXPRESSION_DEBUG_H
#include <poincare/expression.h>
#include <poincare/integer.h>
namespace Poincare {
void print_expression(const Expression * e, int indentationLevel = 0);
void print_prime_factorization(Integer * outputFactors, Integer * outputCoefficients, int outputLength);
}