File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ class cudm_state {
99
99
// / @return The new state after multiplying scalar with the current state.
100
100
cudm_state &operator *=(const std::complex<double > &scalar);
101
101
102
+ cudm_state operator *(double scalar) &&;
103
+
104
+ double norm () const ;
105
+
102
106
private:
103
107
std::vector<std::complex<double >> rawData_;
104
108
std::complex<double > *gpuData_;
Original file line number Diff line number Diff line change @@ -181,6 +181,21 @@ cudm_state &cudm_state::operator*=(const std::complex<double> &scalar) {
181
181
return *this ;
182
182
}
183
183
184
+ cudm_state cudm_state::operator *(double scalar) && {
185
+ this ->operator *=(scalar);
186
+ return std::move (*this );
187
+ }
188
+
189
+ double cudm_state::norm () const {
190
+ std::vector<std::complex<double >> rawData = this ->get_raw_data ();
191
+
192
+ double norm = 0.0 ;
193
+ for (const auto &val : rawData) {
194
+ norm += std::norm (val);
195
+ }
196
+ return std::sqrt (norm);
197
+ }
198
+
184
199
std::string cudm_state::dump () const {
185
200
if (!is_initialized ()) {
186
201
throw std::runtime_error (" State is not initialized." );
You can’t perform that action at this time.
0 commit comments