Beispiel #1
0
 def runTest(self):
     fp = lambda e: mpmath.matrix([[e, e], [e, e]])
     rk.use_mpmath_types()
     cal = rk.get_asym_calc(cu.rydbergs, [0, 0])
     dmat = rk.get_dmat_from_continuous(rk.Smat, fp, cal, 1., 5., 10,
                                        "dum4")
     self.assertEqual(nw.mode, nw.mode_mpmath)
     self.assertEqual(nw.dps, nw.dps_default_mpmath)
     for mat in dmat.values():
         nw.shape(mat)  # Will get an exception if types are wrong.
Beispiel #2
0
 def runTest(self):
     data = {}
     data[1.] = mpmath.matrix([[1., 1.], [1., 1.]])
     data[2.] = mpmath.matrix([[2., 2.], [2., 2.]])
     rk.use_mpmath_types()
     cal = rk.get_asym_calc(cu.rydbergs, [0, 0])
     dmat = rk.get_dmat_from_discrete(rk.Smat, data, cal, "dum2")
     self.assertEqual(nw.mode, nw.mode_mpmath)
     self.assertEqual(nw.dps, nw.dps_default_mpmath)
     for mat in dmat.values():
         nw.shape(mat)  # Will get an exception if types are wrong.
Beispiel #3
0
def _check_coeff_input(enes, smatdata, asymcalc):
    first_shape = nw.shape(smatdata[enes[0]])
    excStr = ""
    if first_shape[0] == 0 or first_shape[0] != first_shape[1]:
        excStr = "Bad Input: Matrix not square"
    if first_shape[0] != asymcalc.get_number_channels():
        excStr = "Bad Input: Inconsistent channel specification"
    if first_shape != nw.shape(smatdata[enes[-1]]):
        excStr = "Bad Input: S-matrices have difference shapes"
    if len(smatdata) < 2:
        excStr = "Bad Input: Not enough Data"
    if len(smatdata) < 2:
        excStr = "Bad Input: Specified fit size too small"
    if len(smatdata) > len(smatdata):
        excStr = "Bad Input: Specified fitsize larger than number of data"
    if len(smatdata) % len(smatdata) != 0:
        excStr = "Bad Input: Num of data is not a multiple of the fit size"
    if len(smatdata) % 2 != 0:
        excStr = "Bad Input: Number of data not even"
    if len(smatdata) % 2 != 0:
        excStr = "Bad Input: Fit size not even"
    if excStr != "":
        raise ParSmatException(excStr)
Beispiel #4
0
def _calculate_coefficients(enes, smatdata, asymcalc):
    num_data = len(smatdata)
    num_poly_terms = num_data / 2
    num_coeffs = num_poly_terms + 1
    num_channels = nw.shape(smatdata[enes[0]])[0]
    alphas = _initialise_coefficients(num_coeffs, num_channels)
    betas = _initialise_coefficients(num_coeffs, num_channels)

    for j in range(num_channels):
        sys_mat = nw.matrix(
            _get_sys_mat_init(num_data, num_channels, num_poly_terms))
        res_vec = nw.matrix(_get_res_vec_init(num_data, num_channels))
        for i in range(num_channels):
            ei = 0
            for ene in enes:
                for ti in range(
                        num_poly_terms
                ):  #We have two indices ci (coefficient) and ti (term). We know the first term in the poly expansion so num_coeffs = num_poly_terms + 1
                    exp = ti + 1
                    for k in range(num_channels):
                        if k == i:
                            alpha_coeff = _primary_alpha(
                                smatdata, asymcalc, i, j, ene, exp)
                            beta_coeff = _primary_beta(smatdata, asymcalc, i,
                                                       j, ene, exp)
                        else:
                            alpha_coeff = _secondary_alpha(
                                smatdata, asymcalc, i, j, k, ene, exp)
                            beta_coeff = _secondary_beta(
                                smatdata, asymcalc, i, j, k, ene, exp)
                        sys_mat[
                            _row(num_data, i, ei),
                            _alpha_index(num_poly_terms, k, ti)] = alpha_coeff
                        sys_mat[_row(num_data, i, ei),
                                _beta_index(num_poly_terms, num_channels, k, ti
                                            )] = beta_coeff
                res_vec[_row(num_data, i, ei),
                        0] = _result(smatdata, i, j, ene)
                ei += 1
        coeff_vec = nw.lin_solve(sys_mat, res_vec)
        _copy_column_coeffs(alphas, betas, coeff_vec, num_poly_terms,
                            num_channels, num_coeffs, j)
    return alphas, betas
Beispiel #5
0
 def valshape(self):
     return nw.shape(self[self.keys()[0]])