File: sl_ex.cpp

package info (click to toggle)
newmat 1.10.4-5
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 1,240 kB
  • ctags: 1,984
  • sloc: cpp: 16,900; makefile: 76; sh: 10
file content (33 lines) | stat: -rw-r--r-- 652 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// This is an example of the use of solution to find the cube root of 
// the integers -10 to 10

// you will need to compile and link solution.cpp and except.cpp

#define WANT_STREAM
#define WANT_MATH

#include "include.h"
#include "solution.h"

#ifdef use_namespace
using namespace RBD_LIBRARIES;
#endif


// the cube class

class Cube : public R1_R1
{ Real operator()() { return x*x*x; } };

int main()
{
   // construct the Cube object
   Cube cube;
   // and then the solve object
   OneDimSolve cube_root(cube);
   // Now do the solves
   for (int i=-10; i<=10; i++)
      cout << i << "   "  << cube_root.Solve(i,0,1.5) << endl;
   return 0;
}