Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 397
    • Issues 397
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2514
Closed
Open
Created Nov 11, 2025 by Thomas Koopman@thomasDeveloper

Axis-notation does not work on complex

The following code:

use StdIO: all;
use Structures: all;
use Math: all;

complex omega(int j, int n) {
  angle = -2.0 * pi() * tod(j) / tod(n);
  return toc(cos(angle), sin(angle));
}

complex[n] DFT(complex[n] x) {
  return {[k] -> sum({[j] -> x[j] * omega(k * j, n)})
              | [k] < [n]};
}

complex[m, r] FFT_2D(complex[r, m] X) {
  n = r * m;
  W = {[., s] -> DFT(X[., s])};
  V = {[t, s] -> omega(s * t, n) * W[t, s]};
  Z = {[s, t] -> W[t, s]};
  Y = {[., t] -> DFT(Z[., t])};
  return Y;
}

int main()
{
  m = 16;
  r = 2;
  n = m * r;

  frequency = 3;

  x = {[j] -> cos(2d * pi() * tod(j) * tod(frequency) / tod(n)) | [j] < [n]};

  y = FFT_2D(reshape([m, r], x));

  return toi(sum(y));
}

gives error

./fft.sac:17: abort:
    16.   n = r * m;
  → 17.   W = {[., s] -> DFT(X[., s])};
    18.   V = {[t, s] -> omega(s * t, n) * W[t, s]};
    19.   Z = {[s, t] -> W[t, s]};

  No definition found for a function "sacprelude_p::sel" that accepts an argument of type
  "Structures::complex[.]" as parameter no 2. Full argument types are "( int[1]{0},
  Structures::complex[.])".
Compilation failed while Running type inference system.

I use the compiler of !447 (merged)

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking