Commit 6008ad21 authored by Davis King's avatar Davis King

Made the resizable_tensor's assignment operator work in a more sensible way.

parent 7272bc74
......@@ -332,31 +332,12 @@ namespace dlib
const matrix_exp<EXP>& item
)
{
if (!(num_samples() == item.nr() && k()*nr()*nc() == item.nc()))
set_size(item.nr(), item.nc());
tensor::operator=(item);
return *this;
}
template <typename EXP>
resizable_tensor& operator+= (
const matrix_exp<EXP>& item
)
{
set_size(item.nr(), item.nc());
tensor::operator+=(item);
return *this;
}
template <typename EXP>
resizable_tensor& operator-= (
const matrix_exp<EXP>& item
)
{
set_size(item.nr(), item.nc());
tensor::operator-=(item);
return *this;
}
void set_size(
long n_, long k_ = 1, long nr_ = 1, long nc_ = 1
)
......
......@@ -495,6 +495,9 @@ namespace dlib
requires
- item contains float values
ensures
- if (num_samples() == item.nr() && k()*nr()*nc() == item.nc()) then
- the dimensions of this tensor are not changed
- else
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
......@@ -502,38 +505,6 @@ namespace dlib
- Assigns item to *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) = item;
!*/
template <typename EXP>
resizable_tensor& operator+= (
const matrix_exp<EXP>& item
);
/*!
requires
- item contains float values
ensures
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
- #nc() == 1
- Adds item to *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) += item;
!*/
template <typename EXP>
resizable_tensor& operator-= (
const matrix_exp<EXP>& item
);
/*!
requires
- item contains float values
ensures
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
- #nc() == 1
- Subtracts item from *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) -= item;
!*/
};
void serialize(const tensor& item, std::ostream& out);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment