mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 00:00:44 +01:00
[poincare] Add a debug method to print prime factorization
Change-Id: I7dfa25bd67cdc1c5388f718aa7363c4dd52c0b66
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user