MCPcopy Create free account
hub / github.com/numpy/numpy / eigh_wrapper

Function eigh_wrapper

numpy/linalg/umath_linalg.cpp:1505–1576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1503
1504template<typename typ>
1505static inline void
1506eigh_wrapper(char JOBZ,
1507 char UPLO,
1508 char**args,
1509 npy_intp const *dimensions,
1510 npy_intp const *steps)
1511{
1512 using basetyp = basetype_t<typ>;
1513 ptrdiff_t outer_steps[3];
1514 size_t iter;
1515 size_t outer_dim = *dimensions++;
1516 size_t op_count = (JOBZ=='N')?2:3;
1517 EIGH_PARAMS_t<typ> eigh_params;
1518 int error_occurred = get_fp_invalid_and_clear();
1519
1520 for (iter = 0; iter < op_count; ++iter) {
1521 outer_steps[iter] = (ptrdiff_t) steps[iter];
1522 }
1523 steps += op_count;
1524
1525 if (init_evd(&eigh_params,
1526 JOBZ,
1527 UPLO,
1528 (fortran_int)dimensions[0], dispatch_scalar<typ>())) {
1529 LINEARIZE_DATA_t matrix_in_ld;
1530 LINEARIZE_DATA_t eigenvectors_out_ld;
1531 LINEARIZE_DATA_t eigenvalues_out_ld;
1532
1533 init_linearize_data(&matrix_in_ld,
1534 eigh_params.N, eigh_params.N,
1535 steps[1], steps[0]);
1536 init_linearize_data(&eigenvalues_out_ld,
1537 1, eigh_params.N,
1538 0, steps[2]);
1539 if ('V' == eigh_params.JOBZ) {
1540 init_linearize_data(&eigenvectors_out_ld,
1541 eigh_params.N, eigh_params.N,
1542 steps[4], steps[3]);
1543 }
1544
1545 for (iter = 0; iter < outer_dim; ++iter) {
1546 int not_ok;
1547 /* copy the matrix in */
1548 linearize_matrix((typ*)eigh_params.A, (typ*)args[0], &matrix_in_ld);
1549 not_ok = call_evd(&eigh_params);
1550 if (!not_ok) {
1551 /* lapack ok, copy result out */
1552 delinearize_matrix((basetyp*)args[1],
1553 (basetyp*)eigh_params.W,
1554 &eigenvalues_out_ld);
1555
1556 if ('V' == eigh_params.JOBZ) {
1557 delinearize_matrix((typ*)args[2],
1558 (typ*)eigh_params.A,
1559 &eigenvectors_out_ld);
1560 }
1561 } else {
1562 /* lapack fail, set result to nan */

Callers

nothing calls this directly

Calls 10

get_fp_invalid_and_clearFunction · 0.85
init_evdFunction · 0.85
init_linearize_dataFunction · 0.85
linearize_matrixFunction · 0.85
call_evdFunction · 0.85
delinearize_matrixFunction · 0.85
nan_matrixFunction · 0.85
update_pointersFunction · 0.85
release_evdFunction · 0.85
set_fp_invalid_or_clearFunction · 0.85

Tested by

no test coverage detected