Skip to content

helpers for half-complex #107

@richard-uk1

Description

@richard-uk1

Would you accept a PR for helpers to handle half-complex arrays. I'm thinking for half-complex arrays x, y,

  • x * y
  • mod(x) or abs(x)
  • arg(x) (or phase(x) if preferred)

the signature could be e.g.

/// contents of y are replaced with the result
fn half_complex_mult<X>(x: &[X], y: &mut [X]) 
where X: f32 or f64 // (either define a trait or 2 functions)
{
    assert_eq!(x.len(), y.len());
    let n = x.len();

    y[0] = y[0] * x[0];
    for i in 1..=(n - 1) / 2 {
        let xre = x[i];
        let yre = y[i];
        let xim = x[n - i];
        let yim = y[n - i];
        y[i] = xre * yre - xim * yim;
        y[n - i] = xre * yim + xre * yim;
    }
    if n % 2 == 0 {
        let n2 = n / 2;
        y[n2] = y[n2] * x[n2];
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions