Skip to content

Commit

Permalink
Fixed Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
danvim committed Feb 27, 2019
1 parent 7bb3d94 commit 39bdcf6
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 104 deletions.
3 changes: 1 addition & 2 deletions Impressionist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
#include "Cluster.h"
#include "PowerIter.h"
using namespace Eigen;
using namespace std;

ImpressionistUI *impUI;
ImpressionistDoc *impDoc;
Bayesian* imp_bayesian;
stringstream ss;
std::stringstream ss;

int main(int argc,
char** argv)
Expand Down
8 changes: 2 additions & 6 deletions ImpressionistUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,16 +741,12 @@ Fl_Menu_Item ImpressionistUI::menuitems[] = {
{ "&Load Another Img", FL_ALT + 'l', (Fl_Callback*)ImpressionistUI::cb_load_another_image },
{ "&Load Mural Img", FL_ALT + 'm', (Fl_Callback*)ImpressionistUI::cb_load_mural_image },
{ "&Load Alpha Map Img", FL_ALT + 'a', (Fl_Callback*)ImpressionistUI::cb_load_alpha_map_image },
<<<<<<< HEAD
{ "Video Auto-Fill", 0, VideoProcessor::cbVideoAutoFill },
{ "Video Paintly", 0, VideoProcessor::cbVideoPaintly },
{ "Bayesian", 0, (Fl_Callback*)ImpressionistUI::cb_bayesian_open_and_solve },
== == == = { "Video", 0, nullptr, nullptr, FL_SUBMENU },
{ "Video", 0, nullptr, nullptr, FL_SUBMENU },
{ "Video Auto-Fill", 0, VideoProcessor::cbVideoAutoFill },
{ "Video Paintly", 0, VideoProcessor::cbVideoPaintly },
{ "Video Painterly", 0, VideoProcessor::cbVideoPaintly },
{ nullptr },
{ "Mosaic...", 0, MosaicBuilder::openUi },
>>>>>>> origin/master
{ 0 },
{ "&Help", 0, 0, 0, FL_SUBMENU },
{ "&About", FL_ALT + 'a', (Fl_Callback*)ImpressionistUI::cb_about },
Expand Down
16 changes: 8 additions & 8 deletions Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "PowerIter.h"
#include "Bayesian.h"

Test::Test(stringstream ss):Tester(ss)
Test::Test(std::stringstream ss):Tester(ss)
{
}

Expand Down Expand Up @@ -114,20 +114,20 @@ void Test::eig()
-6.944444, 119.44445444, 20.83333333,
-27.083333, 20.8333333, 63.19445444;
// EigenSolver<MatrixXd> es(cov1);
// ss <<"~1~"<<endl<< es.eigenvalues().real()<<endl << es.eigenvectors().real()<<endl;
// ss <<"~1~"<<std::endl<< es.eigenvalues().real()<<std::endl << es.eigenvectors().real()<<std::endl;
PowerIter ess(cov1);
ss << "~1~22222\n" << ess.l << endl << ess.e << endl;
ss << "err" << VectorXd(cov1*ess.e - ess.l*ess.e).norm() << endl;
ss << "~1~22222\n" << ess.l << std::endl << ess.e << std::endl;
ss << "err" << VectorXd(cov1*ess.e - ess.l*ess.e).norm() << std::endl;

Matrix3d cov2;
cov2 << 1283.81, -1182.31, 2643.28,
-1182.31, 1089.14, -2434.61,
2643.28, -2434.61, 20442.9;
// EigenSolver<MatrixXd> es2(cov2);
// ss << "~2~" << es2.eigenvalues().real() << es2.eigenvectors().real() << endl;
// ss << "~2~" << es2.eigenvalues().real() << es2.eigenvectors().real() << std::endl;
PowerIter ess2(cov2);
ss << "~2~2222\n" << ess2.l << endl << ess2.e << endl;
ss << "err" << VectorXd(cov2*ess2.e - ess2.l*ess2.e).norm() << endl;
ss << "~2~2222\n" << ess2.l << std::endl << ess2.e << std::endl;
ss << "err" << VectorXd(cov2*ess2.e - ess2.l*ess2.e).norm() << std::endl;
}

void Test::concat()
Expand All @@ -137,7 +137,7 @@ void Test::concat()
A12 << 5, 6, 7, 8;
A21 << 9, 10, 11, 12;
A22 << 13, 14, 15, 16;
ss << A11 << endl << A12 << endl << A21 << endl << A22 << endl;
ss << A11 << std::endl << A12 << std::endl << A21 << std::endl << A22 << std::endl;
Matrix4d A;
A << A11, A12, A21, A22;
ss << A;
Expand Down
3 changes: 1 addition & 2 deletions Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
#include <Eigen/Dense>
#include "Tester.h"
using namespace Eigen;
using namespace std;

class Test: public Tester
{
public:
Test(stringstream ss);
Test(std::stringstream ss);
~Test();
void node();
void cluster();
Expand Down
42 changes: 21 additions & 21 deletions Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Tester::Tester(std::stringstream& ss): ss(ss)
// concat();
// solveClusters();
// calAlpha();
// OutputDebugString(ss.str().c_str());
// OutputDebugstd::string(ss.str().c_str());
}


Expand All @@ -19,58 +19,58 @@ Tester::~Tester()
}


bool Tester::it(const string des, const MatrixXd& expect, const MatrixXd& given, double esp) const
bool Tester::it(const std::string des, const MatrixXd& expect, const MatrixXd& given, double esp) const
{
ss << des << ": ";
MatrixXd diff = expect - given;
if (diff.squaredNorm() < esp)
{
ss << "OK" << endl;
ss << "OK" << std::endl;
return true;
}
ss << "Error\nExpected:" << endl;
ss << expect << endl;
ss << "Found:" << endl;
ss << given << endl;
ss << "Error\nExpected:" << std::endl;
ss << expect << std::endl;
ss << "Found:" << std::endl;
ss << given << std::endl;
return false;
}

bool Tester::it(const string des, const VectorXd& expect, const VectorXd& given, double esp) const
bool Tester::it(const std::string des, const VectorXd& expect, const VectorXd& given, double esp) const
{
ss << des << ": ";
VectorXd diff = expect - given;
if (diff.squaredNorm() < esp)
{
ss << "OK" << endl;
ss << "OK" << std::endl;
return true;
}
ss << "Error\nExpected:" << endl;
ss << expect << endl;
ss << "Found:" << endl;
ss << given << endl;
ss << "Error\nExpected:" << std::endl;
ss << expect << std::endl;
ss << "Found:" << std::endl;
ss << given << std::endl;
return false;
}


auto Tester::it(const string des, double expect, double given, double esp) -> bool
auto Tester::it(const std::string des, double expect, double given, double esp) -> bool
{
ss << des << ": ";
double diff = expect - given;
if (diff < esp)
{
ss << "OK" << endl;
ss << "OK" << std::endl;
return true;
}
ss << "Error\nExpect:" << endl;
ss << expect << endl;
ss << "Found:" << endl;
ss << given << endl;
ss << "Error\nExpect:" << std::endl;
ss << expect << std::endl;
ss << "Found:" << std::endl;
ss << given << std::endl;
return false;
}

bool Tester::it(const string des, bool flag) const
bool Tester::it(const std::string des, bool flag) const
{
ss << des << ": ";
ss << (flag ? "OK" : "Error") << endl;
ss << (flag ? "OK" : "Error") << std::endl;
return flag;
}
11 changes: 5 additions & 6 deletions Tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
#include <string>
#include <Eigen/Dense>
using namespace Eigen;
using namespace std;

class Tester
{
public:
Tester(std::stringstream& ss);
~Tester();

bool it(string des, const MatrixXd& expect, const MatrixXd& given, double esp = 0.1) const;
bool it(string des, const VectorXd& expect, const VectorXd& given, double esp = 0.1) const;
bool it(string des, double expect, double given, double esp = 0.1);
bool it(string des, bool flag) const;
bool it(std::string des, const MatrixXd& expect, const MatrixXd& given, double esp = 0.1) const;
bool it(std::string des, const VectorXd& expect, const VectorXd& given, double esp = 0.1) const;
bool it(std::string des, double expect, double given, double esp = 0.1);
bool it(std::string des, bool flag) const;

stringstream& ss;
std::stringstream& ss;
};
2 changes: 1 addition & 1 deletion VideoProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string>
#include <functional>
#include "impressionistUI.h"
#include "bitmap.h"
#include "Bitmap.h"

class Fl_Widget;

Expand Down
Binary file modified background.bmp
Binary file not shown.
Binary file modified foreground.bmp
Binary file not shown.
5 changes: 2 additions & 3 deletions impressionist.vcxproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down Expand Up @@ -108,7 +107,7 @@
<Optimization>MaxSpeed</Optimization>
<SuppressStartupBanner>true</SuppressStartupBanner>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>C:\Users\dipsy\Desktop\course\COMP4411\projects\1\ImpSkelS17;local\include;local\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(MSBuildProjectDirectory);local\include;local\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>C:\temp\</AssemblerListingLocation>
<PrecompiledHeaderOutputFile>C:\temp\impressionist.pch</PrecompiledHeaderOutputFile>
Expand Down
Loading

0 comments on commit 39bdcf6

Please sign in to comment.