cordic | Trigonometric functions for fixed-point numbers

 by   sebcrozet Rust Version: Current License: BSD-3-Clause

kandi X-RAY | cordic Summary

kandi X-RAY | cordic Summary

cordic is a Rust library. cordic has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

Trigonometric functions for fixed-point numbers
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              cordic has a low active ecosystem.
              It has 5 star(s) with 3 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 1 open issues and 0 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of cordic is current.

            kandi-Quality Quality

              cordic has no bugs reported.

            kandi-Security Security

              cordic has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              cordic is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              cordic releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cordic
            Get all kandi verified functions for this library.

            cordic Key Features

            No Key Features are available at this moment for cordic.

            cordic Examples and Code Snippets

            No Code Snippets are available at this moment for cordic.

            Community Discussions

            QUESTION

            See SFINAE reason for a certain function
            Asked 2021-Jun-07 at 14:09

            I'm using CLang. Is there a way for a certain function or whole .cpp to treat SFINAE as error? If there is an option --sfinae-as-error, or #pragma sfinae_disable/#pragma sfinae_enable for a certain function?

            It seems that due to SFINAE my function specialization has disappeared (became unusable) and I don't know how to find the reason why it has failed (where SFINAE comes from), basically I have unintentional SFINAE case and I want to find out the line that causes it.

            To explain this, I have a small method:

            ...

            ANSWER

            Answered 2021-Jun-07 at 14:08

            Basically my build system just outputted last screen of errors, it truncated errors to last screen showing on console. Of cause in the beginning of screen it showed tiny message that truncation happened but I didn't noticed that. And when I restored whole log there appeared following lines:

            Source https://stackoverflow.com/questions/67872441

            QUESTION

            Trigonometric functions for single-precision floating point numbers in VHDL
            Asked 2019-Dec-16 at 07:31

            How to calculate trigonometric functions: arctangent, arcsine or, at least, sine and cosine in VHDL? I have a value in IEEE 754 single-precision floating-point format (t.e. a sign, a mantissa, an exponent) (picture below). As I know, it could be implemented as a look-up table or via CORDIC algorithm. Both implementations are suitable for me. Precision up to Pi/1000 would be enought. The implementation should be synthesizable. Device - Artix-7 FPGA.

            Similar code in C:

            ...

            ANSWER

            Answered 2019-Dec-11 at 17:36

            You said "I have a value in IEEE 754 single-precision floating-point format ". I would definitely try to avoid using IEEE format numbers. It make things unnecessary complex. I don't know where that number came from or how you got that into the FPGA but the first thing to do is to try to convert that to a fixed point format.

            Xilinx have off-the-shelf Cordic code for you for Arc Tan. That would make your life a lot easier. As expected it does not accept IEEE numbers but does work with "signed fractions" and precision sizes between 8 and 48 bits. You should get their Cordic IP manual and read up on what it can do. I have not seen Cordic code for asin yet.

            You might need to put in some effort to control the I/O as the IP only works with streaming AXI4 interfaces.

            What does surprise me is that you provide you example in C code but are talking about using VHDL. I would expect anybody familiar with C to use (System) Verilog as the langues are very, very close. Also at the risk of upsetting some people: if at all possible use System Verilog. Verilog has had several more iterations then VHDL and is much closer to how modern languages are used these days.

            Source https://stackoverflow.com/questions/59289796

            QUESTION

            How do I calculate sine/cosine/tangent from CORDIC, Taylor Series, or alternative in Python?
            Asked 2019-Nov-12 at 21:50

            I am making a library for math functions, intended to test and challenge my programming and math skills. A necessary part of this is trig: Sine, Cosine, Tangent, and derivatives/inverses, using degrees or radians.

            I have spent hours searching the web for implementation of Taylor Series or CORDIC algorithm using degrees AND/OR radians, to no avail.

            ...

            ANSWER

            Answered 2019-Nov-12 at 21:50

            The Taylor series for the sin function is straightforward to implement. Note that any reference which gives a Taylor series for a trigonometric function will assume the input is in radians, unless specified otherwise.

            Source https://stackoverflow.com/questions/58807798

            QUESTION

            sine computation with CORDIC results in not precise values
            Asked 2019-May-16 at 10:14

            I am trying to implement the CORDIC algorithm for approximating a sine function in single precision, on architecture with no FPU. I compare the result obtained from my implementation with results obtained from standard C math functions. I tried implementing in two ways: 1) directly using floating-point operations, 2) converting the input to fixed-point and using integer based operations. I compare the results obtained from sinf(), sin() and sin() cast to float. The comparison is based on comparing the hexadecimal representations of the result with the expected from math functions.

            In (1) the implementation uses double types, then the result is cast to float. My calculated values are always off by at least one hexadecimal digit, no matter how many iterations are done with CORDIC.

            In (2), initially the input was mapped to a 32 bit integer. The error was the same as in (1). Only after, increasing the fixed point size to 64 bit (and the number of iterations to 64) the precision improved. But yet, there are ranges of input for which the algorithm is not precise. If I would increase the fixed point size to 128 bit (and the number of iterations to 128), it may be enough to obtain precise values but it is completely unpractical.

            The algorithm in (1) is a modified version from the book https://www.jjj.de/fxt/fxtbook.pdf

            ...

            ANSWER

            Answered 2019-May-16 at 10:14

            I gave it a shot but as mentioned in the comments you can not expect exact bit match as math goniometrics is usually based on Chebyshev polynomials. Also you do not have defined the cordic_1K constant. After some search I managed to do this in C++/VCL:

            Source https://stackoverflow.com/questions/56148283

            QUESTION

            How to use a fixed point sin function in Vivado HLS
            Asked 2017-Dec-10 at 11:22

            I am calculating the intersection point of two lines given in the polar coordinate system:

            ...

            ANSWER

            Answered 2017-Dec-10 at 11:22

            With the help of one of my colleagues I figured out a quite easy solution that does not require any hand written implementations or manipulation of the fixed point data:

            use #include "hls_math.h" and the hls::sinf() and hls::cosf() functions.

            It is important to say that the input of the functions should be ap_fixed<32, I> where I <= 32. The output of the functions can be assigned to different types e.g., ap_fixed<16, I>

            Example:

            Source https://stackoverflow.com/questions/47654991

            QUESTION

            atan2 approximation with 11bits in mantissa on x86(with SSE2) and ARM(with vfpv4 NEON)
            Asked 2017-Sep-16 at 16:32

            I'm trying to implement fast atan2(float) with 11 bits accuracy in mantissa. The atan2 implementation will be used for image processing. So it might be better to be implemented with SIMD instruction(The impl targeting x86(with SSE2) & ARM(with vpfv4 NEON)).

            For now, I use chebyshev polynomial approximation(https://jp.mathworks.com/help/fixedpoint/examples/calculate-fixed-point-arctangent.html).

            I'm willing to implement vectorized code manually. I will use SSE2(or later) & NEON wrapper library. I plan or tried these implementation option

            • vectorized Polynomial approximation
              • chebyshev polynomial(now implemented)
            • scalar look up table ( + linear interpolation)
            • vectorized look up table (is this possible? I'm not familiar with NEON, so I don' know some instructions like VGATHER in NEON)
            • vectorized CORDIC method (this may be slow since it require 12+ rotation iterations to get 11bits accuracy)

            else good idea?

            ...

            ANSWER

            Answered 2017-Sep-16 at 16:32

            The first thing you would want to check is whether your compiler is able to vectorize atan2f (y,x) when applied to an array of floats. This usually requires at least a high optimization level such as -O3 and possibly specifying a relaxed "fast math" mode, in which errno handling, denormals and special inputs such as infinities and NaNs are largely ignored. With this approach, accuracy may be well in excess of what is required, but it may be hard to beat a carefully tuned library implementation with respect to performance.

            The next thing to try is to write a simple scalar implementation with sufficient accuracy, and have the compiler vectorize it. Typically this means avoiding anything but very simple branches which can be converted to branchless code through if-conversion. An example of such code is the fast_atan2f() shown below. With the Intel compiler, invoked as icl /O3 /fp:precise /Qvec_report=2 my_atan2f.c, this is vectorized successfully: my_atan2f.c(67): (col. 9) remark: LOOP WAS VECTORIZED. Double checking the generated code through disassembly shows that fast_atan2f() has been inlined and vectorized using SSE instructions of the *ps flavor.

            If all else fails, you could translate the code of fast_atan2() into platform-specific SIMD intrinsics by hand, which should not be all that hard to do. I do not have sufficient experience to do it quickly though.

            I have used a very simple algorithm in this code, which is a simple argument reduction to produce a reduced argument in [0,1], followed by a minimax polynomial approximation, and a final step mapping the result back to the full circle. Core approximation was generated with the Remez algorithm and is evaluated using a 2nd-order Horner scheme. Fused-multiply add (FMA) can be used where available. Special cases involving infinities, NaNs, or 0/0 are not handled, for the sake of performance.

            Source https://stackoverflow.com/questions/46210708

            QUESTION

            Issues with bisection method square root calculation
            Asked 2017-Aug-05 at 16:10
            #include
            #include
            #include
            using namespace std;
            double bisection(double errorVal, double userNum){
                double upper=userNum, lower=0;
                double mid=(lower+upper)/2.0;
                while(!(fabs(mid*mid-userNum)<=errorVal)){
                    mid=(lower+upper)/2.0;
                    if(mid*mid>userNum){
                        upper=mid;
                    }else{
                        lower=mid;
                    }
                }
                return mid;
            }
            
            int main(){
                double errorVal=0, userNum=0;
                std::cout<<"Please enter a number (larger than 0) to calculate its square root, and the desired margin of error."<>userNum>>errorVal;
                bisection(errorVal,userNum);
                std::cout<<"The calculated result is "<<<<". The amount of error is "<
            ...

            ANSWER

            Answered 2017-Aug-05 at 16:00

            Square roots of numbers smaller than 1 are larger then the initial number (remember the root function). As userNum is the upper bound of possible results, those roots cannot be computed with your code. As a solution: add

            Source https://stackoverflow.com/questions/45522593

            QUESTION

            Swift CORDIC Algorithm gives constant answer
            Asked 2017-Jul-14 at 20:29

            I tried to translate the MATLAB language on Cordic wikipedia webpage

            However when I type those:

            ...

            ANSWER

            Answered 2017-Jul-14 at 20:29

            You get the same result for different input because in

            Source https://stackoverflow.com/questions/45110321

            QUESTION

            How to calculate sin inverse (arcsin) in VHDL?
            Asked 2017-Jul-01 at 14:24

            I am using Altera De0 nano Soc FPGA, and Quartus 16.1 lite edition. After doing a search on internet, I found that to get sin, cos and atan Altera's CORDIC IP core can be used directly. And also found lookup table (LUT) can be used for sin or cos (mostly available in google) but how to get sin inverse (ARCSIN) in VHDL? I have found a sin and cos lookup table, is there a way to generate sin inverse?

            ...

            ANSWER

            Answered 2017-Jun-29 at 09:40

            Yes there is.

            For instance using CORDIC...One of my first hits on Google: A survey of CORDIC algorithms for FPGA based computer

            Source https://stackoverflow.com/questions/44816506

            QUESTION

            Calculating inverse trigonometric functions with formulas
            Asked 2017-May-31 at 07:36

            I have been trying to create custom calculator for calculating trigonometric functions. Aside from Chebyshev pylonomials and/or Cordic algorithm I have used Taylor series which have been accurate by few places of decimal.

            This is what i have created to calculate simple trigonometric functions without any modules:

            ...

            ANSWER

            Answered 2017-May-30 at 18:02

            The question is broad in scope, but here are some simple ideas (and code!) that might serve as a starting point for computing arctan. First, the good old Taylor series. For simplicity, we use a fixed number of terms; in practice, you might want to decide the number of terms to use dynamically based on the size of x, or introduce some kind of convergence criterion. With a fixed number of terms, we can evaluate efficiently using something akin to Horner's scheme.

            Source https://stackoverflow.com/questions/44249104

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install cordic

            You can download it from GitHub.
            Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/sebcrozet/cordic.git

          • CLI

            gh repo clone sebcrozet/cordic

          • sshUrl

            git@github.com:sebcrozet/cordic.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Rust Libraries

            996.ICU

            by 996icu

            deno

            by denoland

            rust

            by rust-lang

            alacritty

            by alacritty

            tauri

            by tauri-apps

            Try Top Libraries by sebcrozet

            kiss3d

            by sebcrozetRust

            instant

            by sebcrozetRust

            nrays

            by sebcrozetRust

            rs2cl

            by sebcrozetRust

            mpeg_encoder

            by sebcrozetRust