Skip to content

Commit 0ca3d16

Browse files
committed
Add support for the missing functions
1 parent 9d2f8a4 commit 0ca3d16

File tree

5 files changed

+1012
-49
lines changed

5 files changed

+1012
-49
lines changed

Package.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,19 @@ let package = Package(
1818
.target(
1919
name: "pocketFFT"
2020
),
21+
.target(
22+
name: "CLAPACKHelper",
23+
dependencies: [
24+
.product(name: "CLAPACK", package: "CLAPACK"),
25+
],
26+
publicHeadersPath: "include"
27+
),
2128
.target(
2229
name: "Matft",
2330
dependencies: [
2431
.product(name: "Collections", package: "swift-collections"),
2532
"pocketFFT",
26-
.product(name: "CLAPACK", package: "CLAPACK", condition: .when(platforms: [.wasi])),
33+
.target(name: "CLAPACKHelper", condition: .when(platforms: [.wasi])),
2734
]),
2835
.testTarget(
2936
name: "MatftTests",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// clapack_helper.c
2+
// Wrapper implementations that call CLAPACK functions with correct void signatures.
3+
4+
#include "include/clapack_helper.h"
5+
6+
// Declare the actual CLAPACK functions with correct void return type
7+
// These are the real signatures from the f2c-generated code
8+
extern void dgetrf_(
9+
clapack_int *m,
10+
clapack_int *n,
11+
double *a,
12+
clapack_int *lda,
13+
clapack_int *ipiv,
14+
clapack_int *info
15+
);
16+
17+
extern void dgetri_(
18+
clapack_int *n,
19+
double *a,
20+
clapack_int *lda,
21+
clapack_int *ipiv,
22+
double *work,
23+
clapack_int *lwork,
24+
clapack_int *info
25+
);
26+
27+
void clapack_dgetrf_wrapper(
28+
clapack_int *m,
29+
clapack_int *n,
30+
double *a,
31+
clapack_int *lda,
32+
clapack_int *ipiv,
33+
clapack_int *info
34+
) {
35+
dgetrf_(m, n, a, lda, ipiv, info);
36+
}
37+
38+
void clapack_dgetri_wrapper(
39+
clapack_int *n,
40+
double *a,
41+
clapack_int *lda,
42+
clapack_int *ipiv,
43+
double *work,
44+
clapack_int *lwork,
45+
clapack_int *info
46+
) {
47+
dgetri_(n, a, lda, ipiv, work, lwork, info);
48+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// clapack_helper.h
2+
// This header provides correct function signatures for CLAPACK functions.
3+
// The CLAPACK header incorrectly declares these as returning int,
4+
// but the actual f2c-generated implementation returns void.
5+
6+
#ifndef CLAPACK_HELPER_H
7+
#define CLAPACK_HELPER_H
8+
9+
// On wasm32, long is 32-bit
10+
typedef long clapack_int;
11+
12+
// Wrapper functions that call CLAPACK with correct void return type
13+
void clapack_dgetrf_wrapper(
14+
clapack_int *m,
15+
clapack_int *n,
16+
double *a,
17+
clapack_int *lda,
18+
clapack_int *ipiv,
19+
clapack_int *info
20+
);
21+
22+
void clapack_dgetri_wrapper(
23+
clapack_int *n,
24+
double *a,
25+
clapack_int *lda,
26+
clapack_int *ipiv,
27+
double *work,
28+
clapack_int *lwork,
29+
clapack_int *info
30+
);
31+
32+
#endif // CLAPACK_HELPER_H

0 commit comments

Comments
 (0)