Skip to content

Commit 4c6537d

Browse files
authored
Fix function IDs in C API (#2793)
Small PR to grab the ID from the function signature rather than the `id` attribute in the C API. Actual logic change is the first commit (37ba4c0).
1 parent 2839f0e commit 4c6537d

File tree

4 files changed

+137
-74
lines changed

4 files changed

+137
-74
lines changed

docs/api/qiskit-c/sparse-observable.mdx

+50-50
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
1616

1717
**Functions**
1818

19-
### \_CPPv411qk\_obs\_zero8uint32\_t
19+
### qk\_obs\_zero
2020

21-
<Function id="_CPPv411qk_obs_zero8uint32_t" signature="QkSparseObservable *qk_obs_zero(uint32_t num_qubits)">
21+
<Function id="qk_obs_zero" signature="QkSparseObservable *qk_obs_zero(uint32_t num_qubits)">
2222
Construct the zero observable (without any terms).
2323

2424
<span id="group__QkSparseObservable_1autotoc_md3" />
@@ -38,9 +38,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
3838
A pointer to the created observable.
3939
</Function>
4040

41-
### \_CPPv415qk\_obs\_identity8uint32\_t
41+
### qk\_obs\_identity
4242

43-
<Function id="_CPPv415qk_obs_identity8uint32_t" signature="QkSparseObservable *qk_obs_identity(uint32_t num_qubits)">
43+
<Function id="qk_obs_identity" signature="QkSparseObservable *qk_obs_identity(uint32_t num_qubits)">
4444
Construct the identity observable.
4545

4646
<span id="group__QkSparseObservable_1autotoc_md4" />
@@ -60,9 +60,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
6060
A pointer to the created observable.
6161
</Function>
6262

63-
### \_CPPv410qk\_obs\_new8uint32\_t8uint64\_t8uint64\_tP11QkComplex64P9QkBitTermP8uint32\_tP9uintptr\_t
63+
### qk\_obs\_new
6464

65-
<Function id="_CPPv410qk_obs_new8uint32_t8uint64_t8uint64_tP11QkComplex64P9QkBitTermP8uint32_tP9uintptr_t" signature="QkSparseObservable *qk_obs_new(uint32_t num_qubits, uint64_t num_terms, uint64_t num_bits, QkComplex64 *coeffs, QkBitTerm *bit_terms, uint32_t *indices, uintptr_t *boundaries)">
65+
<Function id="qk_obs_new" signature="QkSparseObservable *qk_obs_new(uint32_t num_qubits, uint64_t num_terms, uint64_t num_bits, QkComplex64 *coeffs, QkBitTerm *bit_terms, uint32_t *indices, uintptr_t *boundaries)">
6666
Construct a new observable from raw data.
6767

6868
<span id="group__QkSparseObservable_1autotoc_md5" />
@@ -113,9 +113,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
113113
If the input data was coherent and the construction successful, the result is a pointer to the observable. Otherwise a null pointer is returned.
114114
</Function>
115115

116-
### \_CPPv411qk\_obs\_freeP18QkSparseObservable
116+
### qk\_obs\_free
117117

118-
<Function id="_CPPv411qk_obs_freeP18QkSparseObservable" signature="void qk_obs_free(QkSparseObservable *obs)">
118+
<Function id="qk_obs_free" signature="void qk_obs_free(QkSparseObservable *obs)">
119119
Free the observable.
120120

121121
<span id="group__QkSparseObservable_1autotoc_md7" />
@@ -140,9 +140,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
140140
**obs** – A pointer to the observable to free.
141141
</Function>
142142
143-
### \_CPPv415qk\_obs\_add\_termP18QkSparseObservablePK12QkSparseTerm
143+
### qk\_obs\_add\_term
144144
145-
<Function id="_CPPv415qk_obs_add_termP18QkSparseObservablePK12QkSparseTerm" signature="QkExitCode qk_obs_add_term(QkSparseObservable *obs, const QkSparseTerm *cterm)">
145+
<Function id="qk_obs_add_term" signature="QkExitCode qk_obs_add_term(QkSparseObservable *obs, const QkSparseTerm *cterm)">
146146
Add a term to the observable.
147147
148148
<span id="group__QkSparseObservable_1autotoc_md9" />
@@ -182,9 +182,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
182182
An exit code. This is `>0` if the term is incoherent or adding the term fails.
183183
</Function>
184184

185-
### \_CPPv411qk\_obs\_termP18QkSparseObservable8uint64\_tP12QkSparseTerm
185+
### qk\_obs\_term
186186

187-
<Function id="_CPPv411qk_obs_termP18QkSparseObservable8uint64_tP12QkSparseTerm" signature="QkExitCode qk_obs_term(QkSparseObservable *obs, uint64_t index, QkSparseTerm *out)">
187+
<Function id="qk_obs_term" signature="QkExitCode qk_obs_term(QkSparseObservable *obs, uint64_t index, QkSparseTerm *out)">
188188
Get an observable term by reference.
189189

190190
A \[CSparseTerm] contains pointers to the indices and bit terms in the term, which can be used to modify the internal data of the observable. This can leave the observable in an incoherent state and should be avoided, unless great care is taken. It is generally safer to construct a new observable instead of attempting in-place modifications.
@@ -223,9 +223,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
223223
An exit code.
224224
</Function>
225225

226-
### \_CPPv416qk\_obs\_num\_termsPK18QkSparseObservable
226+
### qk\_obs\_num\_terms
227227

228-
<Function id="_CPPv416qk_obs_num_termsPK18QkSparseObservable" signature="uintptr_t qk_obs_num_terms(const QkSparseObservable *obs)">
228+
<Function id="qk_obs_num_terms" signature="uintptr_t qk_obs_num_terms(const QkSparseObservable *obs)">
229229
Get the number of terms in the observable.
230230

231231
<span id="group__QkSparseObservable_1autotoc_md13" />
@@ -254,9 +254,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
254254
The number of terms in the observable.
255255
</Function>
256256

257-
### \_CPPv417qk\_obs\_num\_qubitsPK18QkSparseObservable
257+
### qk\_obs\_num\_qubits
258258

259-
<Function id="_CPPv417qk_obs_num_qubitsPK18QkSparseObservable" signature="uint32_t qk_obs_num_qubits(const QkSparseObservable *obs)">
259+
<Function id="qk_obs_num_qubits" signature="uint32_t qk_obs_num_qubits(const QkSparseObservable *obs)">
260260
Get the number of qubits the observable is defined on.
261261

262262
<span id="group__QkSparseObservable_1autotoc_md15" />
@@ -285,9 +285,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
285285
The number of qubits the observable is defined on.
286286
</Function>
287287

288-
### \_CPPv410qk\_obs\_lenPK18QkSparseObservable
288+
### qk\_obs\_len
289289

290-
<Function id="_CPPv410qk_obs_lenPK18QkSparseObservable" signature="uintptr_t qk_obs_len(const QkSparseObservable *obs)">
290+
<Function id="qk_obs_len" signature="uintptr_t qk_obs_len(const QkSparseObservable *obs)">
291291
Get the number of bit terms/indices in the observable.
292292

293293
<span id="group__QkSparseObservable_1autotoc_md17" />
@@ -316,9 +316,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
316316
The number of terms in the observable.
317317
</Function>
318318

319-
### \_CPPv413qk\_obs\_coeffsP18QkSparseObservable
319+
### qk\_obs\_coeffs
320320

321-
<Function id="_CPPv413qk_obs_coeffsP18QkSparseObservable" signature="QkComplex64 *qk_obs_coeffs(QkSparseObservable *obs)">
321+
<Function id="qk_obs_coeffs" signature="QkComplex64 *qk_obs_coeffs(QkSparseObservable *obs)">
322322
Get a pointer to the coefficients.
323323

324324
This can be used to read and modify the observable’s coefficients. The resulting pointer is valid to read for `qk_obs_num_terms(obs)` elements of `complex double`.
@@ -354,9 +354,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
354354
A pointer to the coefficients.
355355
</Function>
356356
357-
### \_CPPv414qk\_obs\_indicesP18QkSparseObservable
357+
### qk\_obs\_indices
358358
359-
<Function id="_CPPv414qk_obs_indicesP18QkSparseObservable" signature="uint32_t *qk_obs_indices(QkSparseObservable *obs)">
359+
<Function id="qk_obs_indices" signature="uint32_t *qk_obs_indices(QkSparseObservable *obs)">
360360
Get a pointer to the indices.
361361
362362
This can be used to read and modify the observable’s indices. The resulting pointer is valid to read for `qk_obs_len(obs)` elements of size `uint32_t`.
@@ -400,9 +400,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
400400
A pointer to the indices.
401401
</Function>
402402

403-
### \_CPPv417qk\_obs\_boundariesP18QkSparseObservable
403+
### qk\_obs\_boundaries
404404

405-
<Function id="_CPPv417qk_obs_boundariesP18QkSparseObservable" signature="uintptr_t *qk_obs_boundaries(QkSparseObservable *obs)">
405+
<Function id="qk_obs_boundaries" signature="uintptr_t *qk_obs_boundaries(QkSparseObservable *obs)">
406406
Get a pointer to the term boundaries.
407407

408408
This can be used to read and modify the observable’s term boundaries. The resulting pointer is valid to read for `qk_obs_num_terms(obs) + 1` elements of size `size_t`.
@@ -446,9 +446,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
446446
A pointer to the boundaries.
447447
</Function>
448448
449-
### \_CPPv416qk\_obs\_bit\_termsP18QkSparseObservable
449+
### qk\_obs\_bit\_terms
450450
451-
<Function id="_CPPv416qk_obs_bit_termsP18QkSparseObservable" signature="QkBitTerm *qk_obs_bit_terms(QkSparseObservable *obs)">
451+
<Function id="qk_obs_bit_terms" signature="QkBitTerm *qk_obs_bit_terms(QkSparseObservable *obs)">
452452
Get a pointer to the bit terms.
453453
454454
This can be used to read and modify the observable’s bit terms. The resulting pointer is valid to read for `qk_obs_len(obs)` elements of size `uint8_t`.
@@ -492,9 +492,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
492492
A pointer to the bit terms.
493493
</Function>
494494

495-
### \_CPPv415qk\_obs\_multiplyPK18QkSparseObservablePK11QkComplex64
495+
### qk\_obs\_multiply
496496

497-
<Function id="_CPPv415qk_obs_multiplyPK18QkSparseObservablePK11QkComplex64" signature="QkSparseObservable *qk_obs_multiply(const QkSparseObservable *obs, const QkComplex64 *coeff)">
497+
<Function id="qk_obs_multiply" signature="QkSparseObservable *qk_obs_multiply(const QkSparseObservable *obs, const QkComplex64 *coeff)">
498498
Multiply the observable by a complex coefficient.
499499

500500
<span id="group__QkSparseObservable_1autotoc_md27" />
@@ -523,9 +523,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
523523
* **coeff** – The coefficient to multiply the observable with.
524524
</Function>
525525

526-
### \_CPPv423qk\_obs\_multiply\_inplaceP18QkSparseObservablePK11QkComplex64
526+
### qk\_obs\_multiply\_inplace
527527

528-
<Function id="_CPPv423qk_obs_multiply_inplaceP18QkSparseObservablePK11QkComplex64" signature="void qk_obs_multiply_inplace(QkSparseObservable *obs, const QkComplex64 *coeff)">
528+
<Function id="qk_obs_multiply_inplace" signature="void qk_obs_multiply_inplace(QkSparseObservable *obs, const QkComplex64 *coeff)">
529529
Multiply the observable by a complex coefficient inplace.
530530

531531
<span id="group__QkSparseObservable_1autotoc_md29" />
@@ -554,9 +554,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
554554
* **coeff** – The coefficient to multiply the observable with.
555555
</Function>
556556
557-
### \_CPPv414qk\_obs\_composePK18QkSparseObservablePK18QkSparseObservable
557+
### qk\_obs\_compose
558558
559-
<Function id="_CPPv414qk_obs_composePK18QkSparseObservablePK18QkSparseObservable" signature="QkSparseObservable *qk_obs_compose(const QkSparseObservable *right, const QkSparseObservable *left)">
559+
<Function id="qk_obs_compose" signature="QkSparseObservable *qk_obs_compose(const QkSparseObservable *right, const QkSparseObservable *left)">
560560
Compose (multiply) two observables.
561561
562562
<span id="group__QkSparseObservable_1autotoc_md31" />
@@ -587,9 +587,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
587587
`right.compose(left)` which equals the observable `result = left @ right`, in terms of the matrix multiplication `@`.
588588
</Function>
589589

590-
### \_CPPv410qk\_obs\_addPK18QkSparseObservablePK18QkSparseObservable
590+
### qk\_obs\_add
591591

592-
<Function id="_CPPv410qk_obs_addPK18QkSparseObservablePK18QkSparseObservable" signature="QkSparseObservable *qk_obs_add(const QkSparseObservable *left, const QkSparseObservable *right)">
592+
<Function id="qk_obs_add" signature="QkSparseObservable *qk_obs_add(const QkSparseObservable *left, const QkSparseObservable *right)">
593593
Add two observables.
594594

595595
<span id="group__QkSparseObservable_1autotoc_md33" />
@@ -620,9 +620,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
620620
A pointer to the result `left + right`.
621621
</Function>
622622

623-
### \_CPPv413qk\_obs\_appendP18QkSparseObservablePK18QkSparseObservable
623+
### qk\_obs\_append
624624

625-
<Function id="_CPPv413qk_obs_appendP18QkSparseObservablePK18QkSparseObservable" signature="void qk_obs_append(QkSparseObservable *obs, const QkSparseObservable *other)">
625+
<Function id="qk_obs_append" signature="void qk_obs_append(QkSparseObservable *obs, const QkSparseObservable *other)">
626626
Add two observables.
627627

628628
<span id="group__QkSparseObservable_1autotoc_md35" />
@@ -653,9 +653,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
653653
A pointer to the result `left + right`.
654654
</Function>
655655

656-
### \_CPPv419qk\_obs\_canonicalizePK18QkSparseObservabled
656+
### qk\_obs\_canonicalize
657657

658-
<Function id="_CPPv419qk_obs_canonicalizePK18QkSparseObservabled" signature="QkSparseObservable *qk_obs_canonicalize(const QkSparseObservable *obs, double tol)">
658+
<Function id="qk_obs_canonicalize" signature="QkSparseObservable *qk_obs_canonicalize(const QkSparseObservable *obs, double tol)">
659659
Calculate the canonical representation of the observable.
660660

661661
<span id="group__QkSparseObservable_1autotoc_md37" />
@@ -688,9 +688,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
688688
The canonical representation of the observable.
689689
</Function>
690690

691-
### \_CPPv411qk\_obs\_copyPK18QkSparseObservable
691+
### qk\_obs\_copy
692692

693-
<Function id="_CPPv411qk_obs_copyPK18QkSparseObservable" signature="QkSparseObservable *qk_obs_copy(const QkSparseObservable *obs)">
693+
<Function id="qk_obs_copy" signature="QkSparseObservable *qk_obs_copy(const QkSparseObservable *obs)">
694694
Copy the observable.
695695

696696
<span id="group__QkSparseObservable_1autotoc_md39" />
@@ -719,9 +719,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
719719
A pointer to a copy of the observable.
720720
</Function>
721721

722-
### \_CPPv412qk\_obs\_equalPK18QkSparseObservablePK18QkSparseObservable
722+
### qk\_obs\_equal
723723

724-
<Function id="_CPPv412qk_obs_equalPK18QkSparseObservablePK18QkSparseObservable" signature="bool qk_obs_equal(const QkSparseObservable *obs, const QkSparseObservable *other)">
724+
<Function id="qk_obs_equal" signature="bool qk_obs_equal(const QkSparseObservable *obs, const QkSparseObservable *other)">
725725
Compare two observables for equality.
726726

727727
Note that this does not compare mathematical equality, but data equality. This means that two observables might represent the same observable but not compare as equal.
@@ -754,9 +754,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseO
754754
`true` if the observables are equal, `false` otherwise.
755755
</Function>
756756

757-
### \_CPPv412qk\_obs\_printPK18QkSparseObservable
757+
### qk\_obs\_print
758758

759-
<Function id="_CPPv412qk_obs_printPK18QkSparseObservable" signature="void qk_obs_print(const QkSparseObservable *obs)">
759+
<Function id="qk_obs_print" signature="void qk_obs_print(const QkSparseObservable *obs)">
760760
Print the observable.
761761

762762
<span id="group__QkSparseObservable_1autotoc_md43" />
@@ -789,9 +789,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseT
789789
790790
**Functions**
791791
792-
### \_CPPv416qk\_obsterm\_printPK12QkSparseTerm
792+
### qk\_obsterm\_print
793793
794-
<Function id="_CPPv416qk_obsterm_printPK12QkSparseTerm" signature="QkExitCode qk_obsterm_print(const QkSparseTerm *term)">
794+
<Function id="qk_obsterm_print" signature="QkExitCode qk_obsterm_print(const QkSparseTerm *term)">
795795
Print the sparse term.
796796
797797
<span id="group__QkSparseTerm_1autotoc_md45" />
@@ -822,9 +822,9 @@ This is a group of functions for interacting with an opaque (Rust-space) SparseT
822822
The function exit code. This is `>0` if reading the term failed.
823823
</Function>
824824

825-
### \_CPPv412QkSparseTerm
825+
### QkSparseTerm
826826

827-
<Class id="_CPPv412QkSparseTerm" signature="struct QkSparseTerm">
827+
<Class id="QkSparseTerm" signature="struct QkSparseTerm">
828828
*#include \<qiskit.h>*
829829

830830
A term in a \[SparseObservable].
@@ -849,9 +849,9 @@ This is a group of functions for interacting with an opaque (Rust-space) BitTerm
849849

850850
**Functions**
851851

852-
### \_CPPv416qk\_bitterm\_label9QkBitTerm
852+
### qk\_bitterm\_label
853853

854-
<Function id="_CPPv416qk_bitterm_label9QkBitTerm" signature="uint8_t qk_bitterm_label(QkBitTerm bit_term)">
854+
<Function id="qk_bitterm_label" signature="uint8_t qk_bitterm_label(QkBitTerm bit_term)">
855855
Get the label for a bit term.
856856

857857
<span id="group__QkBitTerm_1autotoc_md47" />

scripts/js/lib/api/htmlToMd.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1203,9 +1203,9 @@ test("handle <dl> with className function", async () => {
12031203
),
12041204
).toEqual(`Links of functions:
12051205
1206-
### \\_CPPv411qk\\_obs\\_zero8uint32\\_t
1206+
### qk\\_obs\\_zero
12071207
1208-
<Function id="_CPPv411qk_obs_zero8uint32_t" signature="QkSparseObservable *qk_obs_zero(uint32_t num_qubits)">
1208+
<Function id="qk_obs_zero" signature="QkSparseObservable *qk_obs_zero(uint32_t num_qubits)">
12091209
Construct the zero observable (without any terms).
12101210
12111211
**Parameters**
@@ -1246,9 +1246,9 @@ test("handle <dl> with className struct", async () => {
12461246
),
12471247
).toEqual(`Links of structs:
12481248
1249-
### \\_CPPv412QkSparseTerm
1249+
### QkSparseTerm
12501250
1251-
<Class id="_CPPv412QkSparseTerm" signature="struct QkSparseTerm">
1251+
<Class id="QkSparseTerm" signature="struct QkSparseTerm">
12521252
*#include \\<qiskit.h>*
12531253
12541254
This is a struct.

0 commit comments

Comments
 (0)