ReactOS 0.4.16-dev-340-g0540c21
innerprod_test.cpp
Go to the documentation of this file.
1#include <vector>
2#include <algorithm>
3#include <numeric>
4
6
7#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
8using namespace std;
9#endif
10
11//
12// TestCase class
13//
14class InnerprodTest : public CPPUNIT_NS::TestCase
15{
21
22protected:
23 void inprod0();
24 void inprod1();
25 void inprod2();
26
27 static size_t add(size_t a_, size_t b_) {
28 return a_ + b_;
29 }
30
31 static size_t mult(size_t a_, size_t b_) {
32 return a_ * b_;
33 }
34};
35
37
38//
39// tests implementation
40//
42{
43 int vector1[5] = { 1, 2, 3, 4, 5 };
44 int vector2[5] = { 1, 2, 3, 4, 5 };
45
46 int result;
47 result = inner_product(vector1, vector1 + 5, vector2, 0);
49}
51{
52 vector<size_t> v1(3);
53 vector<size_t> v2(v1.size());
54 for (size_t i = 0; i < v1.size(); ++i) {
55 v1[i] = i + 1;
56 v2[i] = v1.size() - i;
57 }
58 size_t result = inner_product(v1.begin(), v1.end(), v2.begin(), (size_t)0);
60}
62{
63 vector<size_t> v1(3);
64 vector<size_t> v2(v1.size());
65 for(size_t i = 0; i < v1.size(); ++i) {
66 v1[i] = i + 1;
67 v2[i] = v1.size() - i;
68 }
69 size_t result=inner_product(v1.begin(), v1.end(), v2.begin(), (size_t)1, mult, add);
70
72}
_STLP_INLINE_LOOP _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp _Init)
Definition: _numeric.h:61
CPPUNIT_TEST_SUITE(InnerprodTest)
CPPUNIT_TEST(inprod0)
CPPUNIT_TEST(inprod1)
static size_t mult(size_t a_, size_t b_)
CPPUNIT_TEST(inprod2)
static size_t add(size_t a_, size_t b_)
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: features.h:417