#include #include #include #include #include "helper.h" using namespace Poincare; QUIZ_CASE(poincare_product_evaluate) { Complex a[1] = {Complex::Float(2.0f)}; assert_parsed_expression_evaluates_to("1*2", a); Complex b[1] = {Complex::Cartesian(11.0, 7.0)}; assert_parsed_expression_evaluates_to("(3+I)*(4+I)", b); #if MATRICES_ARE_DEFINED Complex c[6] = {Complex::Float(2.0f), Complex::Float(4.0f), Complex::Float(6.0f), Complex::Float(8.0f), Complex::Float(10.0f), Complex::Float(12.0f)}; assert_parsed_expression_evaluates_to("[[1,2][3,4][5,6]]*2", c, 3, 2); Complex d[6] = {Complex::Cartesian(3.0, 1.0), Complex::Cartesian(5.0, 5.0), Complex::Cartesian(9.0, 3.0), Complex::Cartesian(12.0, 4.0), Complex::Cartesian(15.0, 5.0), Complex::Cartesian(18.0, 6.0)}; assert_parsed_expression_evaluates_to("[[1,2+I][3,4][5,6]]*(3+I)", d, 3, 2); assert_parsed_expression_evaluates_to("2*[[1,2][3,4][5,6]]", c, 3, 2); assert_parsed_expression_evaluates_to("(3+I)*[[1,2+I][3,4][5,6]]", d, 3, 2); Complex e[12] = {Complex::Float(11.0f), Complex::Float(14.0f), Complex::Float(17.0f), Complex::Float(20.0f), Complex::Float(23.0f), Complex::Float(30.0f), Complex::Float(37.0f), Complex::Float(44.0f), Complex::Float(35.0f), Complex::Float(46.0f), Complex::Float(57.0f), Complex::Float(68.0f)}; assert_parsed_expression_evaluates_to("[[1,2][3,4][5,6]]*[[1,2,3,4][5,6,7,8]]", e, 3, 4); Complex f[12] = {Complex::Cartesian(11.0, 5.0), Complex::Cartesian(13.0, 9.0), Complex::Cartesian(17.0, 7.0), Complex::Cartesian(20.0, 8.0), Complex::Cartesian(23.0, 0.0), Complex::Cartesian(30.0, 7.0), Complex::Cartesian(37.0, 0.0), Complex::Cartesian(44.0, 0.0), Complex::Cartesian(35.0, 0.0), Complex::Cartesian(46.0, 11.0), Complex::Cartesian(57.0, 0.0), Complex::Cartesian(68.0, 0.0)}; assert_parsed_expression_evaluates_to("[[1,2+I][3,4][5,6]]*[[1,2+I,3,4][5,6+I,7,8]]", f, 3, 4); #endif }