Subversion Repositories gelsvn

Rev

Rev 382 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 382 Rev 595
Line -... Line 1...
-
 
1
/* ----------------------------------------------------------------------- *
-
 
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
-
 
3
 * Copyright (C) the authors and DTU Informatics
-
 
4
 * For license and list of authors, see ../../doc/intro.pdf
-
 
5
 * ----------------------------------------------------------------------- */
-
 
6
 
-
 
7
 /** @file ArithMatFloat.h
-
 
8
  * Abstract matrix class
-
 
9
  */
-
 
10
 
1
#ifndef __CGLA_ARITHMATFLOAT_H__
11
#ifndef __CGLA_ARITHMATFLOAT_H__
2
#define __CGLA_ARITHMATFLOAT_H__
12
#define __CGLA_ARITHMATFLOAT_H__
3
 
13
 
4
#include <vector>
14
#include <vector>
5
#include <iostream>
15
#include <iostream>
Line 151... Line 161...
151
 
161
 
152
      /// Multiply scalar onto matrix. All entries are multiplied by scalar.
162
      /// Multiply scalar onto matrix. All entries are multiplied by scalar.
153
      const MT operator * (ScalarType k) const
163
      const MT operator * (ScalarType k) const
154
	{
164
	{
155
	  MT v_new;
165
	  MT v_new;
156
	  std::transform(data, &data[ROWS], &v_new[0], std::bind2nd(std::multiplies<HVT>(), k));
166
	  std::transform(data, &data[ROWS], &v_new[0], std::bind2nd(std::multiplies<HVT>(), HVT(k)));
157
	  return v_new;
167
	  return v_new;
158
	}
168
	}
159
 
169
 
160
      /// Divide all entries in matrix by scalar.
170
      /// Divide all entries in matrix by scalar.
161
      const MT operator / (ScalarType k) const
171
      const MT operator / (ScalarType k) const
162
	{
172
	{
163
	  MT v_new;
173
	  MT v_new;
164
	  std::transform(data, &data[ROWS], &v_new[0], std::bind2nd(std::divides<HVT>(), k));
174
	  std::transform(data, &data[ROWS], &v_new[0], std::bind2nd(std::divides<HVT>(), HVT(k)));
165
	  return v_new;      
175
	  return v_new;      
166
	}
176
	}
167
 
177
 
168
      /// Assignment multiplication of matrix by scalar.
178
      /// Assignment multiplication of matrix by scalar.
169
      const MT& operator *=(ScalarType k) 
179
      const MT& operator *=(ScalarType k) 
170
	{
180
	{
171
	  std::transform(data, &data[ROWS], data, std::bind2nd(std::multiplies<HVT>(), k));
181
	  std::transform(data, &data[ROWS], data, std::bind2nd(std::multiplies<HVT>(), HVT(k)));
172
	  return static_cast<const MT&>(*this);
182
	  return static_cast<const MT&>(*this);
173
	}
183
	}
174
 
184
 
175
      /// Assignment division of matrix by scalar.
185
      /// Assignment division of matrix by scalar.
176
      const MT& operator /=(ScalarType k) 
186
      const MT& operator /=(ScalarType k) 
177
	{ 
187
	{ 
178
	  std::transform(data, &data[ROWS], data, std::bind2nd(std::divides<HVT>(), k));
188
	  std::transform(data, &data[ROWS], data, std::bind2nd(std::divides<HVT>(), HVT(k)));
179
	  return static_cast<const MT&>(*this);
189
	  return static_cast<const MT&>(*this);
180
	}
190
	}
181
 
191
 
182
      //----------------------------------------------------------------------
192
      //----------------------------------------------------------------------
183
 
193