quil_rs/
macros.rs

1// Copyright 2021 Rigetti Computing
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/// Construct a complex number with the provided real component.
16#[macro_export]
17macro_rules! real {
18    ($value:expr) => {{
19        use num_complex::Complex64;
20        Complex64::new($value, 0f64)
21    }};
22}
23
24/// Construct a complex number with the provided imaginary component.
25#[macro_export]
26macro_rules! imag {
27    ($value:expr) => {{
28        use num_complex::Complex64;
29        Complex64::new(0f64, $value)
30    }};
31}