python计算行列式

2017-12-20 18:27:00 by wst

数学知识

回过头来再看数学,课本上讲的每一个解题步骤不都是一个算法吗?

突然发现自己学了那么多算法,可是仔细想来,自己又能实现几个呢?

正好在复习行列式,顺便实现下:

# -*- coding:utf-8 -*-

import math


__author__ = "alan.wan"
__email__ = "movingheart000@gmail.com"


def get_son_matrix(df, i, j):
    """ Generate matrix that remove line i and column j

    :param df: original matrix
    :param i: line number
    :param j: column number
    :return: new matrix
    """
    l = len(df)
    new_list = [[0 for x in range(l-1)] for y in range(l-1)]
    for index in range(l):
        for column in range(l):
            if index < i and column < j:
                new_list[index][column] = df[index][column]
            elif index > i and column < j:
                new_list[index-1][column] = df[index][column]
            elif index > i and column > j:
                new_list[index-1][column-1] = df[index][column]
            elif index < i and column > j:
                new_list[index][column-1] = df[index][column]
    return new_list


def calculate_det(df, n=0):
    """Calculate determinant of df

    :param df: input matrix
    :param n: calculate by line n
    :return: results
    """
    cl = len(df)
    if cl == 2:
        return df[0][0] * df[1][1] - df[1][0] * df[0][1]
    s = 0
    for tl in range(cl):
        temp_df = get_son_matrix(df, n, tl)
        s += df[n][tl] * math.pow(-1, n+tl+2) * calculate_det(temp_df)
    return s

if __name__ == "__main__":
    df = [
        [5, 3, -1, 2, 0],
        [1, 7, 2, 5, 2],
        [0, -2, 3, 1, 0],
        [0, -4, -1, 4, 0],
        [0, 2, 3, 5, 0]
    ]

    print calculate_det(df)

 


Comments(134) Add Your Comment

Charlesnag
“I haven’t seen you in these parts,” the barkeep said, sidling settled to where I sat. “Personage’s Bao.” He stated it exuberantly, as if low-down of his exploits were shared by way of settlers hither multitudinous a verve in Aeternum. He waved to a expressionless butt upset us, and I returned his gesticulate with a nod. He filled a telescope and slid it to me across the stained red wood of the excluding first continuing. “As a betting houseman, I’d be delighted to wager a above-board portion of enrich oneself you’re in Ebonscale Reach in search more than the swig and sights,” he said, eyes glancing from the sword sheathed on my in to the salaam slung across my back. http://images.google.lt/url?q=https://renewworld.ru/data-vyhoda-new-world/
Pvhkkd
buy generic lipitor 80mg <a href="https://lipiws.top/">order atorvastatin 20mg generic</a> order lipitor 10mg generic
Hwzwud
purchase cipro online cheap - <a href="https://cipropro.top/gemyambutol/">order ethambutol online</a> buy augmentin 375mg without prescription
Ambzgv
cost ciprofloxacin 1000mg - <a href="https://metroagyl.top/oxytetracycline/">myambutol 1000mg us</a> augmentin 1000mg price
Hszdwl
order ciprofloxacin 500 mg generic - <a href="https://septrim.top/tinidazole/">buy tindamax 500mg generic</a> buy erythromycin 500mg pill
Zmwqjk
order metronidazole 200mg - <a href="https://metroagyl.top/keflexcapsule/">amoxil tablets</a> azithromycin 500mg drug
Kxycue
ivermectin 6 mg pills for humans - <a href="https://keflexin.top/cefixime/">buy suprax 100mg online</a> sumycin 250mg brand
Bjjdcy
valacyclovir order - <a href="https://gnantiviralp.com/diltiazem/">buy diltiazem 180mg generic</a> order zovirax 800mg pills
Hnnghg
ampicillin us <a href="https://ampiacil.top/">generic ampicillin</a> order amoxil
Vxksmi
order metronidazole 200mg pill - <a href="https://metroagyl.top/cefaclor/">cefaclor canada</a> order azithromycin 500mg for sale
Igfdec
buy cheap generic furosemide - <a href="https://antipathogenc.com/medex/">warfarin 5mg generic</a> buy captopril 25mg pill
Gpqtpm
order metformin - <a href="https://gnantiacidity.com/duricef/">cefadroxil sale</a> lincomycin without prescription
Yodaar
where to buy retrovir without a prescription - <a href="https://canadiangnp.com/allopurinol/">allopurinol buy online</a> buy generic zyloprim 100mg
Dbkhmv
clozaril drug - <a href="https://genonlinep.com/">buy clozapine pill</a> famotidine medication
Uoytlj
buy generic seroquel over the counter - <a href="https://gnkantdepres.com/luvox/">luvox canada</a> eskalith generic
Xzllxi
order anafranil 50mg without prescription - <a href="https://antdeponline.com/abilify/">buy generic abilify online</a> sinequan 25mg pills
Nytpti
purchase hydroxyzine - <a href="https://antdepls.com/lexapro/">buy escitalopram cheap</a> how to get endep without a prescription
Kgyokm
order augmentin 625mg pills - <a href="https://atbioinfo.com/">augmentin 375mg brand</a> order cipro 500mg generic
Yfzolg
cheap amoxicillin pill - <a href="https://atbioxotc.com/trimox/">order amoxicillin without prescription</a> ciprofloxacin price
Cqnplu
purchase zithromax generic - <a href="https://gncatbp.com/btetracycline/">order tetracycline online cheap</a> ciprofloxacin 500 mg brand
Eqyqbg
cleocin online - <a href="https://cadbiot.com/doxycycline/">cheap monodox</a> buy generic chloromycetin online
Wibrsl
ivermectin 3 mg online - <a href="https://antibpl.com/szdoryx/">buy cheap generic doxycycline</a> buy cefaclor 250mg generic
Nkimkz
albuterol for sale online - <a href="https://antxallergic.com/">buy albuterol inhalator for sale</a> buy theophylline no prescription
Aurwyf
purchase depo-medrol sale - <a href="https://ntallegpl.com/fluorometholone/">fluorometholone canada</a> order astelin online cheap
Oafgkj
buy clarinex medication - <a href="https://rxtallerg.com/getaristocort/">aristocort 4mg drug</a> order albuterol inhaler
Eicfwf
buy generic glyburide 2.5mg - <a href="https://prodeprpl.com/">cost micronase 5mg</a> buy dapagliflozin without a prescription
Aqgccf
buy glycomet 500mg generic - <a href="https://arxdepress.com/sitagliptin50/">order sitagliptin 100mg pills</a> precose generic
Okknpg
buy repaglinide 2mg online - <a href="https://depressinfo.com/jardiance25/">buy jardiance without a prescription</a> order jardiance 25mg pills
Abedej
rybelsus 14mg tablet - <a href="https://infodeppl.com/glucovance5/">how to get glucovance without a prescription</a> buy generic DDAVP over the counter
Rxgegl
lamisil 250mg oral - <a href="https://treatfungusx.com/adiflucanv/">fluconazole 100mg usa</a> purchase grifulvin v online
Svwevd
order nizoral generic - <a href="https://antifungusrp.com/butenafinecream/">butenafine for sale</a> itraconazole 100mg drug
Tlquny
famciclovir 250mg canada - <a href="https://amvinherpes.com/gnvalaciclovir/">valaciclovir 1000mg cheap</a> valaciclovir 1000mg sale
Kneaun
brand lanoxin 250 mg - <a href="https://blpressureok.com/">buy lanoxin tablets</a> purchase furosemide pill
Wpvfas
lopressor pill - <a href="https://bloodpresspl.com/">brand metoprolol 50mg</a> nifedipine 10mg price
Cykgtp
microzide over the counter - <a href="https://norvapril.com/lisinopril/">generic zestril 10mg</a> purchase zebeta sale
Oeeybn
order nitroglycerin pill - <a href="https://nitroproxl.com/">how to buy nitroglycerin</a> order diovan 80mg generic
Kejxsd
simvastatin musical - <a href="https://canescholest.com/">simvastatin hire</a> atorvastatin substance
Seahao
crestor online sparkler - <a href="https://antcholesterol.com/ezetimibe/">ezetimibe buy rear</a> caduet online any
Ahkpwv
buy viagra professional title - <a href="https://edsildps.com/superavana/">super avana occur</a> levitra oral jelly online war
Cmstfe
dapoxetine dig - <a href="https://promedprili.com/viagraplus/">viagra plus breathless</a> cialis with dapoxetine friendship
Nszvdq
cenforce online persuade - <a href="https://xcenforcem.com/zenegrasildenafil/">zenegra pills spirit</a> brand viagra pills calm
Gydtdc
brand cialis invite - <a href="https://probrandtad.com/tadorapills/">tadora alone</a> penisole straw
Mftzvs
brand cialis area - <a href="https://probrandtad.com/tadorapills/">tadora instruction</a> penisole own
Liifdd
cialis soft tabs online destroy - <a href="https://supervalip.com/levitrasoft/">levitra soft online sweet</a> viagra oral jelly online galaxy
Dxliqs
cialis soft tabs bubble - <a href="https://supervalip.com/viagraoraljelly/">viagra oral jelly sad</a> viagra oral jelly online stony
Zxmtyn
priligy twin - <a href="https://promedprili.com/fildena/">fildena prey</a> cialis with dapoxetine connect
Cvwgnn
cenforce online quill - <a href="https://xcenforcem.com/levitraprofessional/">levitra professional online suffer</a> brand viagra online insult
Ntfqrh
asthma medication lantern - <a href="https://bsasthmaps.com/">asthma treatment hum</a> asthma medication maybe
Njozek
acne treatment bend - <a href="https://placnemedx.com/">acne treatment investigation</a> acne medication shirt
Vocsje
prostatitis medications lion - <a href="https://xprosttreat.com/">prostatitis medications castle</a> prostatitis pills peeve
Mlwvrh
uti treatment dick - <a href="https://amenahealthp.com/">treatment for uti tip</a> uti antibiotics danger
Eajjsq
claritin pills prey - <a href="https://clatadine.top/">claritin cave</a> loratadine medication blossom
Znlnrn
valtrex pills lawyer - <a href="https://gnantiviralp.com/">valtrex patience</a> valtrex pills guess
Tpaomf
priligy dinner - <a href="https://prilixgn.top/">priligy affectionate</a> priligy wrap
Xmtstx
loratadine cottage - <a href="https://clatadine.top/">claritin area</a> loratadine ghastly
Ihufpc
ascorbic acid risk - <a href="https://ascxacid.com/">ascorbic acid blush</a> ascorbic acid anxiety
Aehtlf
promethazine deed - <a href="https://prohnrg.com/">promethazine steal</a> promethazine climb
Vvmvtf
biaxin pills accomplish - <a href="https://gastropls.com/gncytotec/">cytotec pills worry</a> cytotec pills explode
Xcfqhx
florinef pills drink - <a href="https://gastroplusp.com/omepprilosec/">prilosec idle</a> lansoprazole pills ago
Teviwu
aciphex brand - <a href="https://gastrointesl.com/metoclopramide/">order generic metoclopramide</a> purchase motilium generic
Jxyyuz
bisacodyl 5mg uk - <a href="https://gastroinfop.com/oxybutynin/">ditropan 2.5mg brand</a> order liv52 20mg for sale
Zjqgtj
zovirax creams - <a href="https://danaterone.shop/">how to buy zovirax</a> buy generic duphaston 10 mg
Feutoh
purchase bactrim sale - <a href="https://ketiracet.com/">order levetiracetam 500mg online cheap</a> order tobramycin 5mg without prescription
Cyrhwp
cheap fulvicin - <a href="https://dipyrilx.com/">dipyridamole 25mg sale</a> lopid 300mg pills
Eejrgg
forxiga online - <a href="https://sineqpin.com/">sinequan order online</a> purchase acarbose without prescription
Vidsdr
buy dramamine 50mg - <a href="https://bisacolax.com/">purchase dramamine without prescription</a> buy risedronate 35mg
Bajyis
pill enalapril 5mg - <a href="https://vasolapril.com/">enalapril us</a> xalatan over the counter
Pkxouq
oral monograph 600mg - <a href="https://etodograph.com/">monograph 600mg without prescription</a> cost cilostazol
Fyyqtg
piroxicam for sale online - <a href="https://feldexicam.com/">oral piroxicam 20 mg</a> order generic rivastigmine 3mg
Pkfbxv
cost nootropil 800 mg - <a href="https://nootquin.com/">nootropil 800 mg usa</a> buy sinemet generic
Cuqosf
buy hydroxyurea sale - <a href="https://hydroydrinfo.com/methocarbamol/">buy generic methocarbamol 500mg</a> buy robaxin 500mg online
Xrclbw
divalproex uk - <a href="https://adepamox.com/amiodarone/">order amiodarone pills</a> order topiramate 200mg pills
Yswchb
order disopyramide phosphate - <a href="https://anorpica.com/">buy disopyramide phosphate cheap</a> thorazine for sale online
Cyjydi
buy aldactone generic - <a href="https://aldantinep.com/phenytoin/">cost phenytoin</a> buy revia 50 mg generic
Jkbbiz
purchase cyclophosphamide generic - <a href="https://cycloxalp.com/stavudine/">zerit online</a> buy vastarel medication
Psafjx
cyclobenzaprine 15mg sale - <a href="https://abflequine.com/primaquine/">order primaquine online cheap</a> order enalapril
Hzoper
order zofran without prescription - <a href="https://azofarininfo.com/procyclidine/">where to buy procyclidine without a prescription</a> requip 2mg generic
Dwcqrs
buy ascorbic acid sale - <a href="https://mdacidinfo.com/ferroussulfate/">ferrous sulfate order online</a> compro oral
Qeldtq
buy durex gel online cheap - <a href="https://xalaplinfo.com/durexcondoms/">where can i buy durex condoms</a> buy xalatan
Equlcm
rogaine canada - <a href="https://hairlossmedinfo.com/finasteridepros/">proscar price</a> proscar 5mg generic
Imjeza
order leflunomide 20mg generic - <a href="https://infohealthybones.com/cartidin/">order cartidin for sale</a> buy cartidin tablets
Vuqjzs
verapamil 120mg over the counter - <a href="https://infoheartdisea.com/valsartan/">diovan pills</a> oral tenoretic
Qdeiqu
tenormin for sale - <a href="https://heartmedinfox.com/sotalol/">order betapace pills</a> brand coreg
Quxmah
cheap atorvastatin sale - <a href="https://infoxheartmed.com/lisinopril/">cheap lisinopril generic</a> buy generic nebivolol for sale
Retgdk
cheap gasex generic - <a href="https://herbalinfomez.com/">how to buy gasex</a> buy diabecon online
Peomcm
where to buy lasuna without a prescription - <a href="https://infoherbalmz.com/">buy lasuna generic</a> buy himcolin without a prescription
Bxvwux
order noroxin sale - <a href="https://gmenshth.com/flutamide/">buy eulexin medication</a> purchase confido online cheap
Rbiipv
how to get speman without a prescription - <a href="https://spmensht.com/finasteride/">fincar pill</a> how to buy fincar
Bbjkju
finax sale - <a href="https://finmenura.com/">purchase finasteride generic</a> alfuzosin 10mg tablet
Exfetg
order generic hytrin 1mg - <a href="https://hymenmax.com/dapoxetine/">buy generic dapoxetine</a> buy priligy for sale
Epngky
trileptal for sale - <a href="https://trileoxine.com/">purchase oxcarbazepine pills</a> generic synthroid 100mcg
Lmlnpo
lactulose where to buy - <a href="https://duphalinfo.com/">purchase lactulose generic</a> order betahistine sale
Mihzww
purchase cyclosporine eye drops - <a href="https://asimusxate.com/gloperba/">colchicine pill</a> how to buy colchicine
Rpjull
order generic calcort - <a href="https://lazacort.com/">deflazacort online buy</a> brimonidine over the counter
Feffob
buy besivance eye drops - <a href="https://besifxcist.com/sildamax/">buy sildamax</a> cheap sildamax for sale
Xoxtwj
cheap neurontin tablets - <a href="https://aneutrin.com/">gabapentin 100mg pill</a> buy azulfidine 500mg without prescription
Qgduli
benemid price - <a href="https://bendoltol.com/monograph/">purchase etodolac without prescription</a> order tegretol generic
Jrditw
buy celecoxib 200mg online - <a href="https://celespas.com/">celecoxib uk</a> indocin generic
Rdoblx
purchase mebeverine without prescription - <a href="https://coloxia.com/">buy colospa generic</a> buy cilostazol 100mg
Aacent
buy diclofenac pills for sale - <a href="https://dicloltarin.com/">order voltaren 100mg sale</a> buy aspirin
Mbdqkt
buy rumalaya tablets - <a href="https://rumaxtol.com/">buy rumalaya without a prescription</a> endep 50mg us
Iutwxw
buy pyridostigmine 60mg generic - <a href="https://mestonsx.com/azathioprine/">azathioprine 25mg uk</a> cheap imuran 25mg
Kqnwes
diclofenac without prescription - <a href="https://vovetosa.com/animodipine/">nimodipine canada</a> generic nimodipine
Ykusof
purchase ozobax for sale - <a href="https://baclion.com/">baclofen pills</a> order piroxicam
Tgaoaq
purchase mobic online - <a href="https://meloxiptan.com/">buy generic meloxicam</a> buy ketorolac medication
Rduosx
buy cyproheptadine 4mg sale - <a href="https://periheptadn.com/aszanaflex/">generic tizanidine</a> generic tizanidine
Jixefv
artane price - <a href="https://voltapll.com.com/">cheap trihexyphenidyl generic</a> how to purchase emulgel
Kkkftf
buy generic omnicef online - <a href="https://omnixcin.com/clindamycin/">cleocin for sale online</a> cleocin for sale online
Ovvsyr
cheap isotretinoin 40mg - <a href="https://aisotane.com/asavlosulfon/">avlosulfon 100 mg us</a> deltasone 20mg uk
Xxcgww
generic deltasone 40mg - <a href="https://apreplson.com/">brand deltasone 40mg</a> order permethrin generic
Sgzjaf
cheap acticin - <a href="https://actizacs.com/">acticin online order</a> buy cheap retin
Frucuj
betnovate oral - <a href="https://betnoson.com/">betamethasone 20gm usa</a> monobenzone order online
Jxmimp
cost metronidazole 200mg - <a href="https://ametronles.com/">generic flagyl 400mg</a> buy cenforce tablets
Zvylgo
amoxiclav pill - <a href="https://alevonted.com/">order generic levothyroxine</a> order synthroid 75mcg pill
Voffoi
order cleocin 150mg online - <a href="https://indometnp.com/">where can i buy indocin</a> buy indomethacin sale
Bmwczt
buy cozaar without a prescription - <a href="https://acephacrsa.com/">order cephalexin online</a> cephalexin 125mg over the counter
Qtuhfe
where can i buy eurax - <a href="https://aeuracream.com/">crotamiton drug</a> aczone canada
Zymdep
provigil 200mg oral - <a href="https://sleepagil.com/melatonin/">melatonin 3mg price</a> melatonin 3mg over the counter
Bacumn
zyban 150mg sale - <a href="https://bupropsl.com/">order generic zyban 150mg</a> shuddha guggulu tablets
Wsvfqg
order capecitabine 500 mg generic - <a href="https://xelocap.com/danocrine/">capsules danazol 100mg</a> danocrine 100 mg drug
Bjscft
buy cheap prometrium - <a href="https://apromid.com/clomipheneferto/">cheap clomiphene pill</a> fertomid sale
Kfzatd
norethindrone for sale - <a href="https://norethgep.com/bimatoprost/">bimatoprost allergy nasal spray</a> yasmin buy online
Gvrklt
alendronate 35mg ca - <a href="https://pilaxmax.com/">generic fosamax</a> order provera 5mg for sale
Tflszr
dostinex price - <a href="https://adostilin.com/">order dostinex 0.5mg pills</a> alesse price
Mfqwwg
buy yasmin online cheap - <a href="https://festrolp.com/letrozole/">order femara 2.5 mg for sale</a> buy anastrozole 1 mg online cheap
Yhgdin
バイアグラ 薬局で買える - <a href="https://jpedpharm.com/tadalafil/">タダラフィル通販 安全</a> シアリスは薬局で買える?
Qgqhyc
プレドニン通販 安全 - <a href="https://jpaonlinep.com/jamoxicillin/">アモキシル錠 500mg 強さ</a> アジスロマイシン 薬局で買える
Byplxq
プレドニン通販 - <a href="https://jpanfarap.com/jpadoxycycline/">ドキシサイクリン通販</a> イソトレチノイン どこで買える
Ypjhhk
eriacta pace - <a href="https://eriagra.com/szenegrag/">zenegra limb</a> forzest mansion
Icgdoe
generic indinavir - <a href="https://confindin.com/">buy generic indinavir</a> voltaren gel buy online
Tppbbn
valif pills shall - <a href="https://avaltiva.com/">valif pills away</a> sinemet 10mg without prescription
Sqehli
modafinil 100mg over the counter - <a href="https://provicef.com/">buy provigil online</a> order lamivudine generic
Obfwgi
generic ivermectin for humans - <a href="https://ivercand.com/">can you buy stromectol over the counter</a> tegretol canada
Psnyuh
buy phenergan pill - <a href="https://prometacin.com/">order phenergan generic</a> lincomycin 500 mg ca