Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
186 lines (152 sloc) 6.46 KB

C++ challenge

We have proposed a C++ challenge for showing the benefits of our technology. The goal is to build a wrapper around two linear systems solver; one dense, and the other one sparse.

The source files have dependencies to 3 well known open source libraries:

  • Eigen Library is headers-only.
  • CSparse is very simple, just a *.h and some *.c files
  • Google GTest is also very portable, independent and prepared to be integrated in other projects.

The challenge consists in building and running the code, in three different platforms: Windows, Linux and Mac. Try solving it by your own means, and then solve the problem with biicode. You'll see how much easier and natural it is!

In this section we explain, step by step, how to solve this challenge with the help of biicode.

Create a new project

Open your console and create a new project named "challenge":

$ bii init challenge
$ cd challenge

Copy the code

Download the challenge sources from github or in zipped format from this link. Copy all the files into challenge/blocks/your_user_name/challenge. If you got the sources from github, you need to replace the #include directives as follows: (#include "sparse/cs.h" => #include "tdavis/sparse/cs.h", #include <eigen/Dense> => #include <eigen/eigen/Dense>, #include "gtest/include/gtest/gtest.h" => #include "google/gtest/include/gtest/gtest.h")

Now you can check for all the code dependencies of the current project using the bii deps command. Please, note that while most of the dependencies are correctly solved, three of them are not. Theses unresolved dependencies have been highlighted in the following figure:

Find and retrieve dependencies

Now that we know that our project has some missing dependencies, we'll show you how easily biicode helps you to automatically retrieve all of them. You only need to write the bii find command. You'll be asked to provide your biicode password, and the client will find and retrieve from our servers any missing dependencies:

At this point, you'll find some new folders and files in your challenge/dep folder. These are the blocks that biicode considers as needed for compiling the project.

Build and run

The final step is to actually compile and run the app. You can accomplish this task with the bii build command and run the executable inside the bin folder:

$ bii build

...

$ cd bin
$ #run solver executable
*************** SPARSE ***************
0: 1
1: 0.5
2: 0.333333
3: 0.25
4: 0.2
5: 0.166667
6: 0.142857
7: 0.125
8: 0.111111
9: 0.1
*************** DENSE ***************
0: 1
1: 0.5
2: 0.333333
3: 0.25
4: 0.2
5: 0.166667
6: 0.142857
7: 0.125
8: 0.111111
9: 0.1

Running the tests is really easy too. Note that in this case one of the tests fails due to sparse solver accuracy, but the execution of the test itself works just fine!.

$ cd bin
$ #run test executable
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from Solver
[ RUN      ] Solver.BasicDiagonalSparse
challenge/blocks/your_user_name/challenge/test1.cpp:21: Failure
Value of: 1./(i+1)
  Actual: 0.5
Expected: sol[i]
Which is: 0.5
challenge/blocks/your_user_name/challenge/test1.cpp:21: Failure
Value of: 1./(i+1)
  Actual: 0.333333
Expected: sol[i]
Which is: 0.333333
[  FAILED  ] Solver.BasicDiagonalSparse (0 ms)
[ RUN      ] Solver.BasicDiagonalDense
[       OK ] Solver.BasicDiagonalDense (1 ms)
[----------] 2 tests from Solver (1 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 1 test case ran. (1 ms total)
[  PASSED  ] 1 test.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] Solver.BasicDiagonalSparse

1 FAILED TEST