microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
library/chemistry/src/Utils.qs
25lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | import Std.Math.AbsD; |
| 5 | |
| 6 | /// # Summary |
| 7 | /// Checks whether a `Double` number is not approximately zero. |
| 8 | /// |
| 9 | /// # Input |
| 10 | /// ## number |
| 11 | /// Number to be checked |
| 12 | /// |
| 13 | /// # Output |
| 14 | /// Returns true if `number` has an absolute value greater than `1e-15`. |
| 15 | function IsNotZero(number : Double) : Bool { |
| 16 | AbsD(number) > 1e-15 |
| 17 | } |
| 18 | |
| 19 | function RangeAsIntArray(range : Range) : Int[] { |
| 20 | mutable arr = []; |
| 21 | for i in range { |
| 22 | arr += [i]; |
| 23 | } |
| 24 | return arr; |
| 25 | } |
| 26 | |