Ejemplo n.º 1
0
 def get_matrix(self):
     mlist = []
     for m in range(self.size):
         rlist = []
         for n in range(self.size):
             rlist.append(nw.complex(self[m][n]))
         mlist.append(rlist)
     return nw.matrix(mlist)
Ejemplo n.º 2
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
Ejemplo n.º 3
0
    def gradient(self):
        keys = self.sorted_keys()
        valshape = self.valshape()

        dVec_diffs = []
        for i in range(valshape[0]):
            dVec_diffs.append(self.create_reduced_dim(i).gradient())

        new_item = self._get_dMat()
        self._set_chart_title_for_new(new_item, " gradient")
        for key in keys:
            new_item[key] = nw.matrix([[0.+0.j]*valshape[1]]*valshape[0])
            for i in range(valshape[0]):
                for j in range(valshape[1]):
                    new_item[key][i,j] = dVec_diffs[i][key][j]
        return new_item
Ejemplo n.º 4
0
import pynumwrap as nw

nw.use_python_types()

#Inelastic data for two channel radial well a=1.0 v1=2.0 v2=2.0 th1=0.0 th2=2.0 lambda=1.0.
smatdata_inel = {
    (1.0 + 0j):
    nw.matrix(
        [[-0.903506179588 + 0.428575061624j, 1.351949645563 + 0.855044226986j],
         [1.351949645563 + 0.855044226986j,
          -10.729076216556 - 1.27943423712j]]),
    (2.4 + 0j):
    nw.matrix([[
        -0.015142011020 + 0.936235906011j, -0.214050508716 - 0.278236280014j
    ], [-0.214050508716 - 0.278236280014j,
        -0.908819049951 - 0.225421575385j]]),
    (3.8 + 0j):
    nw.matrix([[
        0.359311942131 + 0.900883718856j, -0.243477511566 + 0.004706878441j
    ], [-0.243477511566 + 0.004706878441j,
        -0.324224934713 + 0.914097772871j]]),
    (5.2 + 0j):
    nw.matrix(
        [[0.536533824095 + 0.817428091005j, -0.192416562985 + 0.083178350109j],
         [-0.192416562985 + 0.083178350109j,
          0.227866378764 + 0.950859685648j]]),
    (6.6 + 0j):
    nw.matrix(
        [[0.595880541354 + 0.776177020474j, -0.171324245796 + 0.114558352498j],
         [-0.171324245796 + 0.114558352498j,
          0.489628987760 + 0.84722360745j]]),
Ejemplo n.º 5
0
 def cal_pos_neg_imag_sub_mat(self, i):
     return nw.matrix([[float(i), 2 * float(i)],
                       [10 + float(i), 10 + 2 * float(i)]])
Ejemplo n.º 6
0
def _initialise_coefficients(num_coeffs, num_channels):
    coeffs = []
    for _ in range(0, num_coeffs):
        mat = nw.matrix(_get_zero_list_mats(num_channels))
        coeffs.append(mat)
    return coeffs
Ejemplo n.º 7
0
 def finialise(self):
     self.s_calc.finialise()
     self.mat_fin_p = nw.matrix(self.list_fin_p)
     self.mat_fout_p = nw.matrix(self.list_fout_p)
Ejemplo n.º 8
0
 def finialise(self):
     self.mat_fin = nw.matrix(self.list_fin)
     self.mat_fout = nw.matrix(self.list_fout)
     self.mat_fin_inv = nw.invert(self.mat_fin)
Ejemplo n.º 9
0
import pynumwrap as nw
TESTDPS = 40
nw.use_mpmath_types(TESTDPS)

smatdata_inel = {
    nw.mpf('1.0'):
    nw.matrix([[
        nw.mpc(real='-0.9035061795881897271183573871099408926215',
               imag='0.4285750616239281985579964961941083103659'),
        nw.mpc(real='1.35194964556261028295718440465645224833',
               imag='0.855044226986120550015062446068837955507')
    ],
               [
                   nw.mpc(real='1.35194964556261028295718440465645224833',
                          imag='0.855044226986120550015062446068837955507'),
                   nw.mpc(real='-10.72907621655570403075417982784331447184',
                          imag='-1.279434237119580005892120398441009444365')
               ]]),
    nw.mpf('2.4'):
    nw.matrix([[
        nw.mpc(real='-0.01514201102047645349961872516635962963436',
               imag='0.9362359060112529631344928051470581148755'),
        nw.mpc(real='-0.2140505087155649231708634185540283542351',
               imag='-0.2782362800142209028684770156904336133757')
    ],
               [
                   nw.mpc(real='-0.2140505087155649231708634185540283542351',
                          imag='-0.2782362800142209028684770156904336133757'),
                   nw.mpc(real='-0.9088190499507801981491861480368798369446',
                          imag='-0.2254215753849156510585342449105225513031')
               ]]),