Skip to contents

These functions compute and append the L2 norm and squared L2 norm of the frequency dimensions (.dim_* columns) as new columns in a fftab object.

Usage

add_l2nm(x)

add_l2sq(x)

get_l2nm(x)

get_l2sq(x)

Arguments

x

A fftab object containing frequency dimensions (.dim_*) and associated metadata.

Value

A vector or fftab object with additional columns:

  • l2nm: The L2 norm of the frequency dimensions.

  • l2sq: The squared L2 norm of the frequency dimensions.

Details

  • add_l2nm(): Appends a column l2nm containing the L2 norm, calculated as the square root of the sum of squared values across .dim_* columns.

  • add_l2sq(): Appends a column l2sq containing the squared L2 norm, calculated as the sum of squared values across .dim_* columns.

  • get_l2nm(): Returns a numeric vector representing the L2 norm for each row.

  • get_l2sq(): Returns a numeric vector representing the squared L2 norm for each row.

Examples

matrix(1:9, 3) |>
  fftab() |>
  print(n = 3) |>
  add_l2nm() |>
  print(n = 3) |>
  add_l2sq() |>
  print(n = 3)
#> # A tibble: 9 × 3
#>   .dim_1 .dim_2 fx            
#> *  <dbl>  <dbl> <cpl>         
#> 1  0          0 45.0+0.000000i
#> 2  0.333      0 -4.5+2.598076i
#> 3 -0.333      0 -4.5-2.598076i
#> # ℹ 6 more rows
#> # A tibble: 9 × 4
#>   .dim_1 .dim_2 fx              l2nm
#>    <dbl>  <dbl> <cpl>          <dbl>
#> 1  0          0 45.0+0.000000i 0    
#> 2  0.333      0 -4.5+2.598076i 0.333
#> 3 -0.333      0 -4.5-2.598076i 0.333
#> # ℹ 6 more rows
#> # A tibble: 9 × 5
#>   .dim_1 .dim_2 fx              l2nm  l2sq
#>    <dbl>  <dbl> <cpl>          <dbl> <dbl>
#> 1  0          0 45.0+0.000000i 0     0    
#> 2  0.333      0 -4.5+2.598076i 0.333 0.111
#> 3 -0.333      0 -4.5-2.598076i 0.333 0.111
#> # ℹ 6 more rows