7 #include <cuda_runtime.h>
11 cudaMalloc(&d_data, rows * cols *
sizeof(
double));
13 cudaMemcpy(d_data, other.d_data, rows * cols *
sizeof(
double), cudaMemcpyDeviceToDevice);
26 cudaMalloc(&d_data, rows * cols *
sizeof(
double));
28 cudaMemcpy(d_data, other.d_data, rows * cols *
sizeof(
double), cudaMemcpyDeviceToDevice);
34 : rows(other.rows), cols(other.cols), d_data(other.d_data) {
36 other.d_data =
nullptr;
49 d_data = other.d_data;
52 other.d_data =
nullptr;
Represents a matrix with GPU-accelerated operations.
Matrix & operator=(const Matrix &other)
Copy assignment operator.
Matrix(int rows, int cols)
Construct a new Matrix object.
Matrix copy() const
Creates a deep copy of the matrix.
Defines the Matrix class for GPU-accelerated matrix operations.