tarask
6 days ago 532005c6573d95199ce0ffbc33df4c7a0a4c3ef9
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
 * @file Scalar.hpp
 *
 * Defines conversion of matrix to scalar.
 *
 * @author James Goppert <james.goppert@gmail.com>
 */
 
#pragma once
 
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#include "math.hpp"
 
namespace matrix
{
 
template<typename Type>
class Scalar
{
public:
    virtual ~Scalar() {};
 
    Scalar() : _value()
    {
    }
 
    Scalar(const Matrix<Type, 1, 1> & other)
    {
        _value = other(0,0);
    }
 
    Scalar(Type other)
    {
        _value = other;
    }
 
    operator Type &()
    {
        return _value;
    }
 
    operator Type const &() const
    {
        return _value;
    }
 
    operator Matrix<Type, 1, 1>() const {
        Matrix<Type, 1, 1> m;
        m(0, 0) = _value;
        return m;
    }
 
    operator Vector<Type, 1>() const {
        Vector<Type, 1> m;
        m(0) = _value;
        return m;
    }
 
private:
    Type _value;
 
};
 
typedef Scalar<float> Scalarf;
 
} // namespace matrix
 
/* vim: set et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : */