#Matrix NxN
import pandas as pd
import numpy as np
nxn = pd.read_csv('input_1/nxn.csv', delimiter=';')
nxn = nxn.apply(lambda x: x.str.replace(',','.'))
nxn = nxn.to_numpy()
nxn = nxn.astype(np.float)
nxn
#Matrix NxH
nxh = pd.read_csv('input_1/nxh.csv', delimiter=';')
nxh = nxh.apply(lambda x: x.str.replace(',','.'))
nxh = nxh.to_numpy()
nxh = nxh.astype(np.float)
nxh
#Vector Xh
from numpy import array
Vector = array ([500,300,300])
Xh = np.array([500,300,300])
array([500,300,300])
Xh.shape = (3,1)
Xh.astype(np.float)
Xh
print(Xh)
[[500]
[300]
[300]]
#Vector V
V = np.random.normal(100, 0, 192)
V.shape = (192,1)
print(V)
[[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]
[100.]]
#Vector e
# numpy.random.normal() method
e = np.random.normal(0.0, 5.0, 192)
e.shape = (192,1)
print(e)
[[ 0.92233265]
[ 6.19005894]
[ -0.53684705]
[ -3.61519366]
[ -1.76831292]
[ -5.09020643]
[ 2.32490121]
[ 0.58813494]
[ -0.11502386]
[ -0.69583286]
[ -2.15607111]
[ 4.10885122]
[ 3.64321737]
[ 2.6134734 ]
[ -2.37074646]
[ -0.41226942]
[ -5.68862558]
[ 5.56337973]
[ -0.7878586 ]
[ -6.30745769]
[ -2.16878904]
[ -2.7394887 ]
[ -0.54353222]
[ 0.92122184]
[ 0.32405908]
[ -1.06691147]
[ 0.3997131 ]
[ 6.79402506]
[ -3.6694195 ]
[ -2.93975497]
[ -6.91842861]
[ -3.80929695]
[ 10.22898416]
[ -1.67180006]
[ -0.04411992]
[ -0.71822028]
[ -4.11057183]
[ 5.7753984 ]
[ -6.10477949]
[ 1.44803162]
[ -3.36268372]
[ -5.2749176 ]
[ 7.01517528]
[ 8.77837209]
[ 0.3029477 ]
[ 0.87647741]
[ 6.49749353]
[ -4.26331568]
[ -6.87492205]
[ 4.03092661]
[ 1.37935682]
[ 5.65098944]
[ 9.06030352]
[ 6.30345378]
[ 3.7218809 ]
[ 5.08049606]
[ 6.2490336 ]
[ 3.63727266]
[ 3.20077086]
[ -0.35386787]
[ -8.32326874]
[ 9.89756562]
[ -1.93383758]
[ -2.50429076]
[ -0.11634346]
[-11.00468311]
[ 1.4627951 ]
[ -2.82567606]
[ 3.30465892]
[ -2.91285096]
[ 3.50752199]
[ 5.62801781]
[ -6.22867738]
[ -0.96735659]
[ 4.62463985]
[ -5.84448837]
[ 0.06206827]
[ -4.98767675]
[ 2.27658167]
[ -2.48641844]
[ 1.79506492]
[ -1.86795531]
[ 0.92349765]
[ 8.54218186]
[ 6.63244101]
[ 11.72210899]
[ -4.7468657 ]
[-11.52033825]
[ -1.14974793]
[ 2.69023094]
[ -1.10539475]
[ 2.90118414]
[ 4.19913894]
[ -4.47747986]
[ 1.8162005 ]
[ 7.37696706]
[ -1.17692118]
[ -2.64813237]
[ 5.42880506]
[ 7.62970367]
[ 4.48886349]
[ 5.48166433]
[ 1.79268525]
[ -0.1296072 ]
[ -9.91592251]
[ -0.69597037]
[ -2.08323406]
[ 4.65573575]
[ -4.68367747]
[ 1.40790089]
[ -6.66533999]
[ 2.92208669]
[ 2.33261117]
[ -1.97266576]
[ 4.08560823]
[ 4.14704954]
[ -4.91184355]
[ 1.33556949]
[ 2.34853951]
[ -0.62042722]
[ -5.71449518]
[ -7.46368027]
[ 3.72197995]
[ -2.32388835]
[ -6.21787651]
[ 4.83208881]
[ -0.80341028]
[ -1.75876604]
[ -0.52487226]
[ 4.91018588]
[ 6.5050186 ]
[ 3.57519991]
[ -1.49160382]
[ -5.3679394 ]
[ -6.12677012]
[ 4.43185098]
[ 0.0908944 ]
[ -8.78733451]
[ -4.10619677]
[ 1.58913989]
[ -2.03195853]
[ -0.86984649]
[ -4.70381644]
[ -1.10553134]
[ 4.1693267 ]
[ -0.81855585]
[ 4.15751822]
[ -4.05596215]
[ 5.95013729]
[ -3.55134968]
[ 1.12451524]
[ -3.04454711]
[ 5.98585467]
[-10.86119574]
[ 2.24696606]
[ -1.41527226]
[ -5.42199358]
[ -1.25845631]
[ 0.23176227]
[ 8.68832795]
[ -0.10668603]
[ -2.49798946]
[ -3.2197055 ]
[ 10.81201539]
[ 2.90776048]
[ -0.55829852]
[ 5.3270399 ]
[ 2.02151745]
[ -2.66493746]
[ -1.96902961]
[ 5.38140246]
[ -2.09249688]
[ 5.20553692]
[ 3.59270223]
[ 0.83470806]
[ -9.23544184]
[ -0.08443393]
[ -0.18777369]
[-11.43454701]
[ -1.86470626]
[ -3.29921317]
[ 4.84490616]
[ -8.41107303]
[ -5.04910489]
[ -4.14544393]
[ 4.83503115]
[ 10.27572352]
[ -1.60887228]
[ 3.86791607]
[ 4.13394682]
[ 5.6508141 ]
[ -0.68179283]]
#Xn1 = nxn * ( V + e ) + nxh * Xh
Xn1 = np.dot(nxn, (V+e)) + np.dot(nxh,Xh)
pd.DataFrame(Xn1).to_csv("output_1/Xn1.csv",index=False, header=False)
Xn1