Giter Club home page Giter Club logo

aaalligator's Introduction

An attempt at implementing a rust variant of the methods described in "AAA rational approximation on a continuum" 2023 (Toby Driscoll, Yuji Nakatsukasa, Lloyd N. Trefethen) 10.48550/arXiv.2305.03677 https://arxiv.org/abs/2305.03677

Forgive me am i fairly new to programming so i'm pretty sure this code is full of bugs and things i can't work out how to fix yet. It's also missing a fair few features mentioned in the paper like lawson iterations and domains other than [-1, 1] and there are a few logic issues in the code but it otherwise appears to mostly work! :)

I ended up having to make two variants of the code aaaxf (floating point functions) and aaaxc (complex functions) due to not knowing if there was a way to force rust to take either as an input like matlab and julia both often seem to have automatic type conversion.

usage example

use aaalligator::aaaxf;

fn f(x: &f64) -> f64 {
    f64::exp(f64::cos(4.0 * x) - f64::sin(3.0 * x))
}

let a = aaaxf(&f, &150, &0, &(1000.0*f64::EPSILON)).unwrap();
let r = aaaxf(&f, &150, &0, &(1000.0*f64::EPSILON)).unwrap().r;


    println!("f(x) - r(x) {:?}", f(&0.5) - r(&0.5));

    println!("Poles:");
    for i in a.poles {
    println!("{}", i)    
    }
    println!();
    println!("Zeros:");
    for i in a.zeros {
    println!("{}", i)    
    }
    println!("\nfinal error {:?}\n", a.final_error);
f(0.5) - r(0.5) 5.570544026056723e-14

Poles:
-1.4251836349051166-0.55103515549739i
-1.4251836349051166+0.55103515549739i
-1.2793065037823754+-0i
-0.3443656711931881-0.6997077840817748i
-0.3443656711931881+0.6997077840817748i
....

Zeros:
-1.279249421913843+-0i
-0.9766906199466148-0.6647089658203892i
-0.9766906199466148+0.6647089658203892i
-0.8086181116012913-0.6725072603508072i
-0.8086181116012913+0.6725072603508072i
-0.654947258895926-0.7054914738178846i
-0.654947258895926+0.7054914738178846i
...

final error 3.643974011424689e-12

bugs / todo

  • lawson iterations not added at all
  • "imaginary axis or right half-plane" (aaai) and "unit circle or disk" (aaaz) not implemented
  • mystery very larges poles/zeros after solving eigenvalues that don't appear in julia/matlab
  • sometimes results are a bit off from other versions? something to do with the loop exit conditions maybe
  • after adding callable r the parallel examples broke and i don't know how to fix :\
  • the last iteration inside the loop doesn't seem to get saved(?) and the final poles comes out one short? urgh
  • debug builds compiled without opt-level = 1 or higher crash with stack overflow on windows (at least for me)
  • ideally this package would be made closer in implementation to the cleaner/better version of the AAA at https://github.com/complexvariables/RationalFunctionApproximation.jl
  • would be nice to implement a domain colouring method for visualisation of the functions and graphing functionality too

aaalligator's People

Contributors

zinkkkk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.