Add +,-,*,/,neg,pow to CudaMatrix

This commit is contained in:
kradchen
2023-11-20 09:48:39 +08:00
parent aabe9d1fd6
commit 761aea2acc
3 changed files with 585 additions and 112 deletions

View File

@@ -11,6 +11,7 @@ struct PowOperator: public thrust::unary_function<float, float>{
void setExponent(float v){
exponent = v;
}
__host__ __device__
float operator()(const float& x) {
return powf(x, exponent);
@@ -74,12 +75,12 @@ void unaryDiv(float* in1, const float& in2, float* out, unsigned long length){
void unaryPow(float* in1, float N,float* out, unsigned long length){
if (N == 0.0f)
{
thrust::fill(out,out+length,0);
thrust::fill(thrust::device,out,out+length,1);
return;
}
if (N == 1.0f)
{
thrust::copy(in1,in1+length,out);
thrust::copy(thrust::device,in1,in1+length,out);
return;
}
if (N == 2.0f){