github.com/goplus/llgo@v0.8.3/py/math/math.go (about) 1 /* 2 * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package math 18 19 import ( 20 _ "unsafe" 21 22 "github.com/goplus/llgo/py" 23 ) 24 25 // https://docs.python.org/3/library/math.html 26 27 //go:linkname Pi py.pi 28 var Pi *py.Object 29 30 // With one argument, return the natural logarithm of x (to base e). 31 // 32 //go:linkname Log py.log 33 func Log(x *py.Object) *py.Object 34 35 // With two arguments, return the logarithm of x to the given base, calculated 36 // as log(x)/log(base). 37 // 38 //go:linkname LogOf py.log 39 func LogOf(x, base *py.Object) *py.Object 40 41 // Return the natural logarithm of 1+x (base e). The result is calculated in 42 // a way which is accurate for x near zero. 43 // 44 //go:linkname Log1p py.log1p 45 func Log1p(x *py.Object) *py.Object 46 47 // Return the Euclidean norm, sqrt(sum(x**2 for x in coordinates)). This is the 48 // length of the vector from the origin to the point given by the coordinates. 49 // 50 //go:linkname Hypot py.hypot 51 func Hypot(coordinates ...*py.Object) *py.Object