STL
fkt.cpp
Go to the documentation of this file.
1 #include "fkt.h"
2 #include <cassert>
3 #include <iostream>
4 #include <string>
5 #include <vector>
6 using namespace std;
7 
8 
9 double sgn(const double x)
10 {
11  cout << " in double" << endl;
12  double t=0.0;
13  if (x>0.0)
14  {
15  t = 1.0;
16  }
17  else if (x <0.0)
18  {
19  t = -1.0;
20  }
21  else
22  {
23  t = 0.0;
24  }
25  return t;
26 }
27 
28 float sgn(const float x)
29 {
30  cout << " in float" << endl;
31  float t(0.0f);
32  if (x>0.0f)
33  {
34  t = 1.0f;
35  }
36  else if (x <0.0f)
37  {
38  t = -1.0f;
39  }
40  else
41  {
42  t = 0.0f;
43  }
44  return t;
45 }
46 
47 size_t sgn(const string x)
48 {
49  cout << " in string" << endl;
50  return x.size();
51 }
52 
53 // Kopieren eines Vektors
54 // a ist input
55 // b ist output
56 void copy_vek(const vector<int>& a, vector<int>& b)
57 {
58  b.resize(a.size());
59  for (unsigned int k=0; k<a.size(); ++k) b[k] = a[k];
60  return;
61 }
62 
63 void set_value(int& a)
64 {
65  a = -1;
66 }
67 
68 // Rekursive Funktion
69 float mypow(const float x, const int k) // Definition
70 {
71  assert(k>=0);
72  float tmp(1.0f);
73  if (k>=1)
74  {
75  tmp = x*mypow(x,k-1);
76  }
77 // else // abbruchbedingung
78 // {
79 // tmp = 1;
80 // }
81  return tmp;
82 }
83 
84 
85 
void set_value(int &a)
Definition: fkt.cpp:63
float mypow(const float x, const int k)
Definition: fkt.cpp:69
void copy_vek(const vector< int > &a, vector< int > &b)
Definition: fkt.cpp:56
double sgn(const double x)
Definition: fkt.cpp:9