monolish
0.14.2
MONOlithic LIner equation Solvers for Highly-parallel architecture
|
Go to the documentation of this file.
42 template <
typename Float>
class vector {
47 std::vector<Float>
val;
77 vector(
const size_t N,
const Float value);
87 vector(
const std::vector<Float> &vec);
97 vector(
const std::initializer_list<Float> &list);
150 vector(
const Float *start,
const Float *
end);
162 vector(
const size_t N,
const Float
min,
const Float
max);
236 [[nodiscard]]
const Float *
data()
const {
return val.data(); }
244 [[nodiscard]] Float *
data() {
return val.data(); }
256 throw std::runtime_error(
"Error, GPU vector cant use resize");
269 throw std::runtime_error(
"Error, GPU vector cant use push_back");
280 [[nodiscard]]
const Float *
begin()
const {
return val.data(); }
288 [[nodiscard]] Float *
begin() {
return val.data(); }
296 [[nodiscard]]
const Float *
end()
const {
return val.data() +
size(); }
312 [[nodiscard]]
auto size()
const {
return val.size(); }
330 void fill(Float value);
340 void print_all(
bool force_cpu =
false)
const;
350 void print_all(std::string filename)
const;
406 void operator=(
const std::vector<Float> &vec);
429 throw std::runtime_error(
"Error, GPU vector cant use operator[]");
445 bool compare_cpu_and_device =
false)
const;
458 bool compare_cpu_and_device =
false)
const;
471 bool compare_cpu_and_device =
false)
const;
void min(const matrix::CRS< double > &A, const matrix::CRS< double > &B, matrix::CRS< double > &C)
Create a new CRS matrix with smallest elements of two matrices (C[0:nnz] = min(A[0:nnz],...
std::vector< Float > val
size N vector data
Float * data()
returns a direct pointer to the vector
size_t get_offset() const
vector< Float > operator-()
Sign inversion.
void max(const matrix::CRS< double > &A, const matrix::CRS< double > &B, matrix::CRS< double > &C)
Create a new CRS matrix with greatest elements of two matrices (C[0:nnz] = max(A[0:nnz],...
const Float * end() const
returns a end iterator
auto size() const
get vector size
auto get_nnz() const
get vector size
Float * end()
returns a end iterator
const Float * data() const
returns a direct pointer to the vector
void operator=(const vector< Float > &vec)
copy vector, It is same as copy ( Copy the memory on CPU and GPU )
Float & operator[](size_t i)
reference to the element at position (v[i])
void push_back(Float val)
Add a new element at the end of the vector (only CPU)
void nonfree_recv()
recv data from GPU (w/o free)
~vector()
destructor of vector, free GPU memory
void print_all(bool force_cpu=false) const
print all elements to standart I/O
bool get_device_mem_stat() const
true: sended, false: not send
const Float * begin() const
returns a begin iterator
bool operator!=(const vector< Float > &vec) const
Comparing vectors (v != vec)
void fill(Float value)
fill vector elements with a scalar value
Float * begin()
returns a begin iterator
bool operator==(const vector< Float > &vec) const
Comparing vectors (v == vec)
void device_free() const
free data on GPU
void send() const
send data to GPU
bool equal(const vector< Float > &vec, bool compare_cpu_and_device=false) const
Comparing matricies (A == mat)
void resize(size_t N)
resize vector (only CPU)
void recv()
recv data from GPU, and free data on GPU
bool gpu_status
true: sended, false: not send