예제 #1
0
def RuleBasedNlg(action,slots):
    response = ''
    data = None
    if action == 'exchange':
        data = exchange(slots[0],slots[1])
        response = "The exchange rate from {0} to {1} is {2}".format( slots[0], slots[1], data)

    elif action == 'get_exchange_rate':
        currency = slots[0]
        ex_type = slots[1]
        direction = slots[2]
        data = get_exchange_rate(slots[0],slots[1],slots[2])
        response = "The {1} exchange rate for {0} NTD {2} {3} is {4} in BANK OF TAIWAN".format(ex_type+'ing', direction, 'from' if ex_type == 'buy' else 'for', currency, data)

    elif action == 'query':
        symbol = name2sym(slots[0])
        date = slots[1]
        data = query(symbol,date)
        item = ['openn', 'high', 'low', 'close', 'volume']
        response = "Share price on date {0}  ".format(date)
        for i in range(len(item)):
            response += "{0} : {1}     ".format(item[i],data[i])
    elif action == 'USDX':
        data = USDX( slots[0], slots[1])
        for i in range(len(data)):
            response += 'Date: ' + data[i][0] + "     USDX: " + data[i][1] + '\n'
    if data == None:
        response = 'Cannot find the match information. Sincerely appologize.'

    return response 
예제 #2
0
def exchange_inverse ( n ):

#*****************************************************************************80
#
## EXCHANGE_INVERSE returns the inverse of the exchange matrix.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    16 March 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer N, the order of the matrix.
#
#    Output, real A(N,N), the matrix.
#
  a = exchange ( n, n )

  return a
예제 #3
0
def RuleBasedNlg(action,slots):
    response = ''
    if action == 'exchange':
        if len(slots) == 2:
            rate = exchange(slots[0],slots[1])
            response = "The exchange rate from {0} to {1} is {2}".format( slots[0], slots[1], rate)
        else:
            response = "The exchange rate from {0} to {1} is {2}"
    elif action == 'get_exchange_rate':
        if len(slots)==3:
            currency = slots[0]
            ex_type = slots[1]
            direction = slots[2]
            rate = get_exchange_rate(slots[0],slots[1],slots[2])
            response = "The {1} exchange rate for {0} NTD {2} {3} is {4} in BANK OF TAIWAN".format(ex_type+'ing', direction, 'from' if ex_type == 'buy' else 'for', currency, rate)
        else:
            response = "The {1} exchange rate for {0} NTD {2} {3} is {4} in BANK OF TAIWAN"
    elif action == 'query':
        if len(slots) == 2:
            symbol = name2sym(slot[0])
            date = slot[1]
            data = query(symbol,date)
            item = ['openn', 'high', 'low', 'close', 'volume']
            response = "Share price on date {0}  ".format(date)
            for i in range(len(item)):
                response += "{0} : {1}     ".format(item[i],data[i])
        else:
            response = "Share price on date {0}  "
    return response 
예제 #4
0
def exchange_test ( ):

#*****************************************************************************80
#
## EXCHANGE_TEST tests EXCHANGE.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    26 January 2015
#
#  Author:
#
#    John Burkardt
#
  from r8mat_print import r8mat_print

  print ''
  print 'EXCHANGE_TEST'
  print '  EXCHANGE computes the EXCHANGE matrix.'

  m = 4
  n = m

  a = exchange ( m, n )
  r8mat_print ( m, n, a, '  EXCHANGE matrix:' )

  print ''
  print 'EXCHANGE_TEST'
  print '  Normal end of execution.'

  return
예제 #5
0
def exchange_inverse(n):

    #*****************************************************************************80
    #
    ## EXCHANGE_INVERSE returns the inverse of the exchange matrix.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    16 March 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    #  Parameters:
    #
    #    Input, integer N, the order of the matrix.
    #
    #    Output, real A(N,N), the matrix.
    #
    a = exchange(n, n)

    return a
예제 #6
0
def exchange_test():

    #*****************************************************************************80
    #
    ## EXCHANGE_TEST tests EXCHANGE.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    26 January 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    from r8mat_print import r8mat_print

    print ''
    print 'EXCHANGE_TEST'
    print '  EXCHANGE computes the EXCHANGE matrix.'

    m = 4
    n = m

    a = exchange(m, n)
    r8mat_print(m, n, a, '  EXCHANGE matrix:')

    print ''
    print 'EXCHANGE_TEST'
    print '  Normal end of execution.'

    return
예제 #7
0
def exchange_determinant_test():

    #*****************************************************************************80
    #
    ## EXCHANGE_DETERMINANT_TEST tests EXCHANGE_DETERMINANT.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    26 January 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    from exchange import exchange
    from r8mat_print import r8mat_print

    print ''
    print 'EXCHANGE_DETERMINANT_TEST'
    print '  EXCHANGE_DETERMINANT computes the determinant of the EXCHANGE matrix.'
    print ''

    m = 4
    n = m

    a = exchange(m, n)
    r8mat_print(m, n, a, '  EXCHANGE matrix:')

    value = exchange_determinant(n)

    print ''
    print '  Value =  %g' % (value)

    print ''
    print 'EXCHANGE_DETERMINANT_TEST'
    print '  Normal end of execution.'

    return
예제 #8
0
def exchange_condition_test():

    #*****************************************************************************80
    #
    ## EXCHANGE_CONDITION_TEST tests EXCHANGE_CONDITION.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    10 February 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    from exchange import exchange
    from r8mat_print import r8mat_print

    print ''
    print 'EXCHANGE_CONDITION_TEST'
    print '  EXCHANGE_CONDITION computes the condition of the EXCHANGE matrix.'
    print ''

    m = 4
    n = m

    a = exchange(m, n)
    r8mat_print(m, n, a, '  EXCHANGE matrix:')

    value = exchange_condition(n)

    print ''
    print '  Value =  %g' % (value)

    print ''
    print 'EXCHANGE_CONDITION_TEST'
    print '  Normal end of execution.'

    return
예제 #9
0
def exchange_determinant_test ( ):

#*****************************************************************************80
#
## EXCHANGE_DETERMINANT_TEST tests EXCHANGE_DETERMINANT.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    26 January 2015
#
#  Author:
#
#    John Burkardt
#
  from exchange import exchange
  from r8mat_print import r8mat_print
 
  print ''
  print 'EXCHANGE_DETERMINANT_TEST'
  print '  EXCHANGE_DETERMINANT computes the determinant of the EXCHANGE matrix.'
  print ''

  m = 4
  n = m

  a = exchange ( m, n )
  r8mat_print ( m, n, a, '  EXCHANGE matrix:' )

  value = exchange_determinant ( n )

  print ''
  print '  Value =  %g' % ( value )

  print ''
  print 'EXCHANGE_DETERMINANT_TEST'
  print '  Normal end of execution.'

  return
예제 #10
0
def exchange_condition_test ( ):

#*****************************************************************************80
#
## EXCHANGE_CONDITION_TEST tests EXCHANGE_CONDITION.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    10 February 2015
#
#  Author:
#
#    John Burkardt
#
  from exchange import exchange
  from r8mat_print import r8mat_print
 
  print ''
  print 'EXCHANGE_CONDITION_TEST'
  print '  EXCHANGE_CONDITION computes the condition of the EXCHANGE matrix.'
  print ''

  m = 4
  n = m

  a = exchange ( m, n )
  r8mat_print ( m, n, a, '  EXCHANGE matrix:' )

  value = exchange_condition ( n )

  print ''
  print '  Value =  %g' % ( value )

  print ''
  print 'EXCHANGE_CONDITION_TEST'
  print '  Normal end of execution.'

  return
예제 #11
0
#coding: utf-8
__author__ = 'terry'
import time
from exchange import exchange

#数据库连接信息
host="localhost"
user="******"
passwd="root"
dbname="exchange"
charset="utf8"

ex = exchange()
conn = ex.makeConnectionToMySQL(host,user,passwd,dbname,charset)
while 1:
    contents = ex.readHtml()
    ex.splitAndStore(contents,conn)
    #每小时更新一次数据
    time.sleep(60*60)
예제 #12
0
파일: orders.py 프로젝트: nextpuma/AXE-Bot
import ccxt
import time
import datetime as dt
from time import sleep
from datetime import timedelta
from notification import notificator
from exchange import exchange, api_requests_frequency
from market_data import check_coin_price
from config import get_config
from balance import fetch_balance

show_error = "YES"

exchange = exchange()
api_requests_frequency = api_requests_frequency()

use_limit_orders = get_config()["use_limit_orders"]
exchange_fee = float(get_config()["exchange_fee"])

use_bnb_for_fee = get_config()["use_bnb_for_fee"]

coin_2 = get_config()["coin_2"].upper()
start_balance = fetch_balance(coin_2)

cancel_order_by_time = get_config()["cancel_order_by_time"]
time_to_cancel_order_by_inactivity_minutes = int(
    get_config()["time_to_cancel_order_by_inactivity_minutes"])

total_profit_for_this_session = 0.0
balance_on_session_start = start_balance
예제 #13
0
#coding: utf-8
__author__ = 'terry'
import time
from exchange import exchange

#数据库连接信息
host=""        // MySQL host
user=""        // MySQL username
passwd=""      // MySQL password
dbname=""      // database name 
charset="utf8" // charset

ex = exchange()
conn = ex.makeConnectionToMySQL(host,user,passwd,dbname,charset)
while 1:
    contents = ex.readHtml()
    ex.splitAndStore(contents,conn)
    #每小时更新一次数据
    time.sleep(60)
예제 #14
0
파일: main.py 프로젝트: korhenon/MiningGame
                def trade(rate_):
                    rate_now = rate_
                    print()
                    print(f"Rate now is {rate_now}")
                    print()
                    print("If you want go on: 1")
                    print("If you want change your coin: 2")
                    print("Quit from exchange: 3")
                    print()

                    decision = input('What do you want to do?: ')
                    if decision == '1':
                        while True:
                            try:
                                r = exchange(rate_now)
                            except TypeError:
                                print(
                                    '---------------------------------------------------------------------'
                                )
                                print("GAME OVER!")
                                print(
                                    f"Your results are {my_kc_wallet_history[-1]}kc and {my_dollar_wallet_history[-1]}$"
                                )
                                break
                            print()
                            trade(r)
                            break
                    elif decision == '2':
                        while True:

                            try:
                                int(rate_now)
                            except ValueError:
                                print(
                                    '---------------------------------------------------------------------'
                                )
                                print("GAME OVER!")
                                print(
                                    f"Your results are {my_kc_wallet_history[-1]}kc and {my_dollar_wallet_history[-1]}$"
                                )
                                break
                            print(
                                f"Your KC wallet: {my_kc_wallet_history[-1]}kc"
                            )
                            try:
                                change_count = int(
                                    input("How much coins you want change?: "))
                            except ValueError:
                                print()
                                print('Error!')
                                print(
                                    '---------------------------------------------------------------------'
                                )
                                trade(rate_now)
                            if change_count <= 0:
                                print()
                                print(
                                    "Error! You can't cnange null or negative amount of coins"
                                )
                                print(
                                    '---------------------------------------------------------------------'
                                )
                                trade(rate_now)

                            if change_count > my_kc_wallet_history[-1]:
                                print()
                                print("Error! You don't have so many coins")
                                print(
                                    '---------------------------------------------------------------------'
                                )
                                trade(rate_now)
                            kc_wallet(-change_count)
                            dollar_wallet(change_count, rate_now)

                            print()
                            print("Ok!")
                            print()

                            print(
                                f"Your KC wallet: {my_kc_wallet_history[-1]}kc"
                            )
                            print(
                                f"Your dollar wallet: {my_dollar_wallet_history[-1]}$"
                            )

                            print(
                                '---------------------------------------------------------------------'
                            )

                            trade(rate_now)

                            break

                    elif decision == '3':
                        print()
                        print("Goodbye!")
                        print(
                            '---------------------------------------------------------------------'
                        )
                        actions(rate_now)
                    else:
                        print()
                        print('Error!')
                        print(
                            '---------------------------------------------------------------------'
                        )
                        trade(rate_now)
예제 #15
0
def exchangeCall(bot: Bot, update: Update):
    exchange.exchange(bot, update)
예제 #16
0
        'Upfront Payment': 'inne',
    }
    deductible = {
        'o-dzielo': decimal.Decimal(0.2),
        'zlecenie': decimal.Decimal(0.2),
        'inne': decimal.Decimal(0),
    }
    need_advance = ['o-dzielo', 'zlecenie',
                    'inne' # nieobowiazkowe
    ]

    paid_advance = paid_advances.get(month, 0)

    for income in month_incomes:
        pln = exchange(amount=float(income.amount),
                       date=income.date,
                       currency='1 USD')
        pln = money_round(decimal.Decimal(pln))
        type = type_map.get(income.type, income.type)
        country = countries[income.client]
        by_country[country] += pln
        sums[type] += pln
        sums_global[type] += pln
        print('%s, kwota: %s USD = %s PLN (before fee %s USD), klient: %s, umowa: %s, kraj: %s' % (
            income.date, income.amount, pln, income.amount_before_fee, income.client, type, country))

    print()
    print('Umowy:')
    for k, v in sums.items():
        print('  %s: %s PLN' % (k, v))
    print('W sumie: %s PLN' % sum(sums.values()))
예제 #17
0
def test_condition():

    #*****************************************************************************80
    #
    ## TEST_CONDITION tests the L1 condition number computations.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    11 April 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    from aegerter import aegerter
    from aegerter import aegerter_condition
    from aegerter import aegerter_inverse
    from bab import bab
    from bab import bab_condition
    from bab import bab_inverse
    from bauer import bauer
    from bauer import bauer_condition
    from bauer import bauer_inverse
    from bis import bis
    from bis import bis_condition
    from bis import bis_inverse
    from biw import biw
    from biw import biw_condition
    from biw import biw_inverse
    from bodewig import bodewig
    from bodewig import bodewig_condition
    from bodewig import bodewig_inverse
    from boothroyd import boothroyd
    from boothroyd import boothroyd_condition
    from boothroyd import boothroyd_inverse
    from combin import combin
    from combin import combin_condition
    from combin import combin_inverse
    from companion import companion
    from companion import companion_condition
    from companion import companion_inverse
    from conex1 import conex1
    from conex1 import conex1_condition
    from conex1 import conex1_inverse
    from conex2 import conex2
    from conex2 import conex2_condition
    from conex2 import conex2_inverse
    from conex3 import conex3
    from conex3 import conex3_condition
    from conex3 import conex3_inverse
    from conex4 import conex4
    from conex4 import conex4_condition
    from conex4 import conex4_inverse
    from daub2 import daub2
    from daub2 import daub2_condition
    from daub2 import daub2_inverse
    from daub4 import daub4
    from daub4 import daub4_condition
    from daub4 import daub4_inverse
    from daub6 import daub6
    from daub6 import daub6_condition
    from daub6 import daub6_inverse
    from daub8 import daub8
    from daub8 import daub8_condition
    from daub8 import daub8_inverse
    from daub10 import daub10
    from daub10 import daub10_condition
    from daub10 import daub10_inverse
    from daub12 import daub12
    from daub12 import daub12_condition
    from daub12 import daub12_inverse
    from diagonal import diagonal
    from diagonal import diagonal_condition
    from diagonal import diagonal_inverse
    from dif2 import dif2
    from dif2 import dif2_condition
    from dif2 import dif2_inverse
    from downshift import downshift
    from downshift import downshift_condition
    from downshift import downshift_inverse
    from exchange import exchange
    from exchange import exchange_condition
    from exchange import exchange_inverse
    from fibonacci2 import fibonacci2
    from fibonacci2 import fibonacci2_condition
    from fibonacci2 import fibonacci2_inverse
    from gfpp import gfpp
    from gfpp import gfpp_condition
    from gfpp import gfpp_inverse
    from givens import givens
    from givens import givens_condition
    from givens import givens_inverse
    from hankel_n import hankel_n
    from hankel_n import hankel_n_condition
    from hankel_n import hankel_n_inverse
    from harman import harman
    from harman import harman_condition
    from harman import harman_inverse
    from hartley import hartley
    from hartley import hartley_condition
    from hartley import hartley_inverse
    from identity import identity
    from identity import identity_condition
    from identity import identity_inverse
    from ill3 import ill3
    from ill3 import ill3_condition
    from ill3 import ill3_inverse
    from jordan import jordan
    from jordan import jordan_condition
    from jordan import jordan_inverse
    from kershaw import kershaw
    from kershaw import kershaw_condition
    from kershaw import kershaw_inverse
    from lietzke import lietzke
    from lietzke import lietzke_condition
    from lietzke import lietzke_inverse
    from maxij import maxij
    from maxij import maxij_condition
    from maxij import maxij_inverse
    from minij import minij
    from minij import minij_condition
    from minij import minij_inverse
    from orth_symm import orth_symm
    from orth_symm import orth_symm_condition
    from orth_symm import orth_symm_inverse
    from oto import oto
    from oto import oto_condition
    from oto import oto_inverse
    from pascal1 import pascal1
    from pascal1 import pascal1_condition
    from pascal1 import pascal1_inverse
    from pascal3 import pascal3
    from pascal3 import pascal3_condition
    from pascal3 import pascal3_inverse
    from pei import pei
    from pei import pei_condition
    from pei import pei_inverse
    from r8_uniform_ab import r8_uniform_ab
    from r8mat_norm_l1 import r8mat_norm_l1
    from r8vec_uniform_ab import r8vec_uniform_ab
    from rodman import rodman
    from rodman import rodman_condition
    from rodman import rodman_inverse
    from rutis1 import rutis1
    from rutis1 import rutis1_condition
    from rutis1 import rutis1_inverse
    from rutis2 import rutis2
    from rutis2 import rutis2_condition
    from rutis2 import rutis2_inverse
    from rutis3 import rutis3
    from rutis3 import rutis3_condition
    from rutis3 import rutis3_inverse
    from rutis5 import rutis5
    from rutis5 import rutis5_condition
    from rutis5 import rutis5_inverse
    from summation import summation
    from summation import summation_condition
    from summation import summation_inverse
    from sweet1 import sweet1
    from sweet1 import sweet1_condition
    from sweet1 import sweet1_inverse
    from sweet2 import sweet2
    from sweet2 import sweet2_condition
    from sweet2 import sweet2_inverse
    from sweet3 import sweet3
    from sweet3 import sweet3_condition
    from sweet3 import sweet3_inverse
    from sweet4 import sweet4
    from sweet4 import sweet4_condition
    from sweet4 import sweet4_inverse
    from tri_upper import tri_upper
    from tri_upper import tri_upper_condition
    from tri_upper import tri_upper_inverse
    from upshift import upshift
    from upshift import upshift_condition
    from upshift import upshift_inverse
    from wilk03 import wilk03
    from wilk03 import wilk03_condition
    from wilk03 import wilk03_inverse
    from wilk04 import wilk04
    from wilk04 import wilk04_condition
    from wilk04 import wilk04_inverse
    from wilk05 import wilk05
    from wilk05 import wilk05_condition
    from wilk05 import wilk05_inverse
    from wilson import wilson
    from wilson import wilson_condition
    from wilson import wilson_inverse

    print ''
    print 'TEST_CONDITION'
    print '  Compute the L1 condition number of an example of each'
    print '  test matrix'
    print ''
    print '  Title                    N            COND            COND'
    print ''
    #
    #  AEGERTER
    #
    title = 'AEGERTER'
    n = 5
    cond1 = aegerter_condition(n)

    a = aegerter(n)
    b = aegerter_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BAB
    #
    title = 'BAB'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    beta, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = bab_condition(n, alpha, beta)

    a = bab(n, alpha, beta)
    b = bab_inverse(n, alpha, beta)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BAUER
    #
    title = 'BAUER'
    n = 6
    cond1 = bauer_condition()

    a = bauer()
    b = bauer_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BIS
    #
    title = 'BIS'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    beta, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = bis_condition(alpha, beta, n)

    a = bis(alpha, beta, n, n)
    b = bis_inverse(alpha, beta, n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BIW
    #
    title = 'BIW'
    n = 5
    cond1 = biw_condition(n)

    a = biw(n)
    b = biw_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BODEWIG
    #
    title = 'BODEWIG'
    n = 4
    cond1 = bodewig_condition()

    a = bodewig()
    b = bodewig_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BOOTHROYD
    #
    title = 'BOOTHROYD'
    n = 5
    cond1 = boothroyd_condition(n)

    a = boothroyd(n)
    b = boothroyd_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  COMBIN
    #
    title = 'COMBIN'
    n = 3
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    beta, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = combin_condition(alpha, beta, n)

    a = combin(alpha, beta, n)
    b = combin_inverse(alpha, beta, n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  COMPANION
    #
    title = 'COMPANION'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    x, seed = r8vec_uniform_ab(n, r8_lo, r8_hi, seed)
    cond1 = companion_condition(n, x)

    a = companion(n, x)
    b = companion_inverse(n, x)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  CONEX1
    #
    title = 'CONEX1'
    n = 4
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = conex1_condition(alpha)

    a = conex1(alpha)
    b = conex1_inverse(alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  CONEX2
    #
    title = 'CONEX2'
    n = 3
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = conex2_condition(alpha)

    a = conex2(alpha)
    b = conex2_inverse(alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  CONEX3
    #
    title = 'CONEX3'
    n = 5
    cond1 = conex3_condition(n)

    a = conex3(n)
    b = conex3_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  CONEX4
    #
    title = 'CONEX4'
    n = 4
    cond1 = conex4_condition()

    a = conex4()
    b = conex4_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB2
    #
    title = 'DAUB2'
    n = 4
    cond1 = daub2_condition(n)

    a = daub2(n)
    b = daub2_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB4
    #
    title = 'DAUB4'
    n = 8
    cond1 = daub4_condition(n)

    a = daub4(n)
    b = daub4_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB6
    #
    title = 'DAUB6'
    n = 12
    cond1 = daub6_condition(n)

    a = daub6(n)
    b = daub6_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB8
    #
    title = 'DAUB8'
    n = 16
    cond1 = daub8_condition(n)

    a = daub8(n)
    b = daub8_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB10
    #
    title = 'DAUB10'
    n = 20
    cond1 = daub10_condition(n)

    a = daub10(n)
    b = daub10_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB12
    #
    title = 'DAUB12'
    n = 24
    cond1 = daub12_condition(n)

    a = daub12(n)
    b = daub12_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DIAGONAL
    #
    title = 'DIAGONAL'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    x, seed = r8vec_uniform_ab(n, r8_lo, r8_hi, seed)
    cond1 = diagonal_condition(n, x)

    a = diagonal(n, n, x)
    b = diagonal_inverse(n, x)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DIF2
    #
    title = 'DIF2'
    n = 5
    cond1 = dif2_condition(n)

    a = dif2(n, n)
    b = dif2_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DOWNSHIFT
    #
    title = 'DOWNSHIFT'
    n = 5
    cond1 = downshift_condition(n)

    a = downshift(n)
    b = downshift_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  EXCHANGE
    #
    title = 'EXCHANGE'
    n = 5
    cond1 = exchange_condition(n)

    a = exchange(n, n)
    b = exchange_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  FIBONACCI2
    #
    title = 'FIBONACCI2'
    n = 5
    cond1 = fibonacci2_condition(n)

    a = fibonacci2(n)
    b = fibonacci2_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  GFPP
    #
    title = 'GFPP'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = gfpp_condition(n, alpha)

    a = gfpp(n, alpha)
    b = gfpp_inverse(n, alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  GIVENS
    #
    title = 'GIVENS'
    n = 5
    cond1 = givens_condition(n)

    a = givens(n, n)
    b = givens_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  HANKEL_N
    #
    title = 'HANKEL_N'
    n = 5
    cond1 = hankel_n_condition(n)

    a = hankel_n(n)
    b = hankel_n_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  HARMAN
    #
    title = 'HARMAN'
    n = 8
    cond1 = harman_condition()

    a = harman()
    b = harman_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  HARTLEY
    #
    title = 'HARTLEY'
    n = 5
    cond1 = hartley_condition(n)

    a = hartley(n)
    b = hartley_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  IDENTITY
    #
    title = 'IDENTITY'
    n = 5
    cond1 = identity_condition(n)

    a = identity(n, n)
    b = identity_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  ILL3
    #
    title = 'ILL3'
    n = 3
    cond1 = ill3_condition()

    a = ill3()
    b = ill3_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  JORDAN
    #
    title = 'JORDAN'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = jordan_condition(n, alpha)

    a = jordan(n, n, alpha)
    b = jordan_inverse(n, alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  KERSHAW
    #
    title = 'KERSHAW'
    n = 4
    cond1 = kershaw_condition()

    a = kershaw()
    b = kershaw_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  LIETZKE
    #
    title = 'LIETZKE'
    n = 5
    cond1 = lietzke_condition(n)

    a = lietzke(n)
    b = lietzke_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  MAXIJ
    #
    title = 'MAXIJ'
    n = 5
    cond1 = maxij_condition(n)

    a = maxij(n, n)
    b = maxij_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  MINIJ
    #
    title = 'MINIJ'
    n = 5
    cond1 = minij_condition(n)

    a = minij(n, n)
    b = minij_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  ORTH_SYMM
    #
    title = 'ORTH_SYMM'
    n = 5
    cond1 = orth_symm_condition(n)

    a = orth_symm(n)
    b = orth_symm_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  OTO
    #
    title = 'OTO'
    n = 5
    cond1 = oto_condition(n)

    a = oto(n, n)
    b = oto_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  PASCAL1
    #
    title = 'PASCAL1'
    n = 5
    cond1 = pascal1_condition(n)

    a = pascal1(n)
    b = pascal1_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  PASCAL3
    #
    title = 'PASCAL3'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = pascal3_condition(n, alpha)

    a = pascal3(n, alpha)
    b = pascal3_inverse(n, alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  PEI
    #
    title = 'PEI'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = pei_condition(alpha, n)

    a = pei(alpha, n)
    b = pei_inverse(alpha, n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RODMAN
    #
    title = 'RODMAN'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = rodman_condition(n, alpha)

    a = rodman(n, n, alpha)
    b = rodman_inverse(n, alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RUTIS1
    #
    title = 'RUTIS1'
    n = 4
    cond1 = rutis1_condition()

    a = rutis1()
    b = rutis1_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RUTIS2
    #
    title = 'RUTIS2'
    n = 4
    cond1 = rutis2_condition()

    a = rutis2()
    b = rutis2_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RUTIS3
    #
    title = 'RUTIS3'
    n = 4
    cond1 = rutis3_condition()

    a = rutis3()
    b = rutis3_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RUTIS5
    #
    title = 'RUTIS5'
    n = 4
    cond1 = rutis5_condition()

    a = rutis5()
    b = rutis5_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SUMMATION
    #
    title = 'SUMMATION'
    n = 5
    cond1 = summation_condition(n)

    a = summation(n, n)
    b = summation_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SWEET1
    #
    title = 'SWEET1'
    n = 6
    cond1 = sweet1_condition()

    a = sweet1()
    b = sweet1_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SWEET2
    #
    title = 'SWEET2'
    n = 6
    cond1 = sweet2_condition()

    a = sweet2()
    b = sweet2_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SWEET3
    #
    title = 'SWEET3'
    n = 6
    cond1 = sweet3_condition()

    a = sweet3()
    b = sweet3_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SWEET4
    #
    title = 'SWEET4'
    n = 13
    cond1 = sweet4_condition()

    a = sweet4()
    b = sweet4_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  TRI_UPPER
    #
    title = 'TRI_UPPER'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = tri_upper_condition(alpha, n)

    a = tri_upper(alpha, n)
    b = tri_upper_inverse(alpha, n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  UPSHIFT
    #
    title = 'UPSHIFT'
    n = 5
    cond1 = upshift_condition(n)

    a = upshift(n)
    b = upshift_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  WILK03
    #
    title = 'WILK03'
    n = 3
    cond1 = wilk03_condition()

    a = wilk03()
    b = wilk03_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  WILK04
    #
    title = 'WILK04'
    n = 4
    cond1 = wilk04_condition()

    a = wilk04()
    b = wilk04_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  WILK05
    #
    title = 'WILK05'
    n = 5
    cond1 = wilk05_condition()

    a = wilk05()
    b = wilk05_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  WILSON
    #
    title = 'WILSON'
    n = 4
    cond1 = wilson_condition()

    a = wilson()
    b = wilson_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  Terminate.
    #
    print ''
    print 'TEST_CONDITION'
    print '  Normal end of execution.'

    return
예제 #18
0
def test_condition ( ):

#*****************************************************************************80
#
## TEST_CONDITION tests the L1 condition number computations.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    11 April 2015
#
#  Author:
#
#    John Burkardt
#
  from aegerter             import aegerter
  from aegerter             import aegerter_condition
  from aegerter             import aegerter_inverse
  from bab                  import bab
  from bab                  import bab_condition
  from bab                  import bab_inverse
  from bauer                import bauer
  from bauer                import bauer_condition
  from bauer                import bauer_inverse
  from bis                  import bis
  from bis                  import bis_condition
  from bis                  import bis_inverse
  from biw                  import biw
  from biw                  import biw_condition
  from biw                  import biw_inverse
  from bodewig              import bodewig
  from bodewig              import bodewig_condition
  from bodewig              import bodewig_inverse
  from boothroyd            import boothroyd
  from boothroyd            import boothroyd_condition
  from boothroyd            import boothroyd_inverse
  from combin               import combin
  from combin               import combin_condition
  from combin               import combin_inverse
  from companion            import companion
  from companion            import companion_condition
  from companion            import companion_inverse
  from conex1               import conex1
  from conex1               import conex1_condition
  from conex1               import conex1_inverse
  from conex2               import conex2
  from conex2               import conex2_condition
  from conex2               import conex2_inverse
  from conex3               import conex3
  from conex3               import conex3_condition
  from conex3               import conex3_inverse
  from conex4               import conex4
  from conex4               import conex4_condition
  from conex4               import conex4_inverse
  from daub2                import daub2
  from daub2                import daub2_condition
  from daub2                import daub2_inverse
  from daub4                import daub4
  from daub4                import daub4_condition
  from daub4                import daub4_inverse
  from daub6                import daub6
  from daub6                import daub6_condition
  from daub6                import daub6_inverse
  from daub8                import daub8
  from daub8                import daub8_condition
  from daub8                import daub8_inverse
  from daub10               import daub10
  from daub10               import daub10_condition
  from daub10               import daub10_inverse
  from daub12               import daub12
  from daub12               import daub12_condition
  from daub12               import daub12_inverse
  from diagonal             import diagonal
  from diagonal             import diagonal_condition
  from diagonal             import diagonal_inverse
  from dif2                 import dif2
  from dif2                 import dif2_condition
  from dif2                 import dif2_inverse
  from downshift            import downshift
  from downshift            import downshift_condition
  from downshift            import downshift_inverse
  from exchange             import exchange
  from exchange             import exchange_condition
  from exchange             import exchange_inverse
  from fibonacci2           import fibonacci2
  from fibonacci2           import fibonacci2_condition
  from fibonacci2           import fibonacci2_inverse
  from gfpp                 import gfpp
  from gfpp                 import gfpp_condition
  from gfpp                 import gfpp_inverse
  from givens               import givens
  from givens               import givens_condition
  from givens               import givens_inverse
  from hankel_n             import hankel_n
  from hankel_n             import hankel_n_condition
  from hankel_n             import hankel_n_inverse
  from harman               import harman
  from harman               import harman_condition
  from harman               import harman_inverse
  from hartley              import hartley
  from hartley              import hartley_condition
  from hartley              import hartley_inverse
  from identity             import identity
  from identity             import identity_condition
  from identity             import identity_inverse
  from ill3                 import ill3
  from ill3                 import ill3_condition
  from ill3                 import ill3_inverse
  from jordan               import jordan
  from jordan               import jordan_condition
  from jordan               import jordan_inverse
  from kershaw              import kershaw
  from kershaw              import kershaw_condition
  from kershaw              import kershaw_inverse
  from lietzke              import lietzke
  from lietzke              import lietzke_condition
  from lietzke              import lietzke_inverse
  from maxij                import maxij
  from maxij                import maxij_condition
  from maxij                import maxij_inverse
  from minij                import minij
  from minij                import minij_condition
  from minij                import minij_inverse
  from orth_symm            import orth_symm
  from orth_symm            import orth_symm_condition
  from orth_symm            import orth_symm_inverse
  from oto                  import oto
  from oto                  import oto_condition
  from oto                  import oto_inverse
  from pascal1              import pascal1
  from pascal1              import pascal1_condition
  from pascal1              import pascal1_inverse
  from pascal3              import pascal3
  from pascal3              import pascal3_condition
  from pascal3              import pascal3_inverse
  from pei                  import pei
  from pei                  import pei_condition
  from pei                  import pei_inverse
  from r8_uniform_ab        import r8_uniform_ab
  from r8mat_norm_l1        import r8mat_norm_l1
  from r8vec_uniform_ab     import r8vec_uniform_ab
  from rodman               import rodman
  from rodman               import rodman_condition
  from rodman               import rodman_inverse
  from rutis1               import rutis1
  from rutis1               import rutis1_condition
  from rutis1               import rutis1_inverse
  from rutis2               import rutis2
  from rutis2               import rutis2_condition
  from rutis2               import rutis2_inverse
  from rutis3               import rutis3
  from rutis3               import rutis3_condition
  from rutis3               import rutis3_inverse
  from rutis5               import rutis5
  from rutis5               import rutis5_condition
  from rutis5               import rutis5_inverse
  from summation            import summation
  from summation            import summation_condition
  from summation            import summation_inverse
  from sweet1               import sweet1
  from sweet1               import sweet1_condition
  from sweet1               import sweet1_inverse
  from sweet2               import sweet2
  from sweet2               import sweet2_condition
  from sweet2               import sweet2_inverse
  from sweet3               import sweet3
  from sweet3               import sweet3_condition
  from sweet3               import sweet3_inverse
  from sweet4               import sweet4
  from sweet4               import sweet4_condition
  from sweet4               import sweet4_inverse
  from tri_upper            import tri_upper
  from tri_upper            import tri_upper_condition
  from tri_upper            import tri_upper_inverse
  from upshift              import upshift
  from upshift              import upshift_condition
  from upshift              import upshift_inverse
  from wilk03               import wilk03
  from wilk03               import wilk03_condition
  from wilk03               import wilk03_inverse
  from wilk04               import wilk04
  from wilk04               import wilk04_condition
  from wilk04               import wilk04_inverse
  from wilk05               import wilk05
  from wilk05               import wilk05_condition
  from wilk05               import wilk05_inverse
  from wilson               import wilson
  from wilson               import wilson_condition
  from wilson               import wilson_inverse

  print ''
  print 'TEST_CONDITION'
  print '  Compute the L1 condition number of an example of each'
  print '  test matrix'
  print ''
  print '  Title                    N            COND            COND'
  print ''
#
#  AEGERTER
#
  title = 'AEGERTER'
  n = 5
  cond1 = aegerter_condition ( n )

  a = aegerter ( n )
  b = aegerter_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BAB
#
  title = 'BAB'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  beta, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = bab_condition ( n, alpha, beta )

  a = bab ( n, alpha, beta )
  b = bab_inverse ( n, alpha, beta )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BAUER
#
  title = 'BAUER'
  n = 6
  cond1 = bauer_condition ( )

  a = bauer ( )
  b = bauer_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BIS
#
  title = 'BIS'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  beta, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = bis_condition ( alpha, beta, n )

  a = bis ( alpha, beta, n, n )
  b = bis_inverse ( alpha, beta, n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BIW
#
  title = 'BIW'
  n = 5
  cond1 = biw_condition ( n )

  a = biw ( n )
  b = biw_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BODEWIG
#
  title = 'BODEWIG'
  n = 4
  cond1 = bodewig_condition ( )

  a = bodewig ( )
  b = bodewig_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BOOTHROYD
#
  title = 'BOOTHROYD'
  n = 5
  cond1 = boothroyd_condition ( n )

  a = boothroyd ( n )
  b = boothroyd_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  COMBIN
#
  title = 'COMBIN'
  n = 3
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  beta, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = combin_condition ( alpha, beta, n )

  a = combin ( alpha, beta, n )
  b = combin_inverse ( alpha, beta, n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  COMPANION
#
  title = 'COMPANION'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  x, seed = r8vec_uniform_ab ( n, r8_lo, r8_hi, seed )
  cond1 = companion_condition ( n, x )

  a = companion ( n, x )
  b = companion_inverse ( n, x )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  CONEX1
#
  title = 'CONEX1'
  n = 4
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = conex1_condition ( alpha )

  a = conex1 ( alpha )
  b = conex1_inverse ( alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  CONEX2
#
  title = 'CONEX2'
  n = 3
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = conex2_condition ( alpha )

  a = conex2 ( alpha )
  b = conex2_inverse ( alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  CONEX3
#
  title = 'CONEX3'
  n = 5
  cond1 = conex3_condition ( n )

  a = conex3 ( n )
  b = conex3_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  CONEX4
#
  title = 'CONEX4'
  n = 4
  cond1 = conex4_condition ( )

  a = conex4 ( )
  b = conex4_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB2
#
  title = 'DAUB2'
  n = 4
  cond1 = daub2_condition ( n )

  a = daub2 ( n )
  b = daub2_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB4
#
  title = 'DAUB4'
  n = 8
  cond1 = daub4_condition ( n )

  a = daub4 ( n )
  b = daub4_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB6
#
  title = 'DAUB6'
  n = 12
  cond1 = daub6_condition ( n )

  a = daub6 ( n )
  b = daub6_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB8
#
  title = 'DAUB8'
  n = 16
  cond1 = daub8_condition ( n )

  a = daub8 ( n )
  b = daub8_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB10
#
  title = 'DAUB10'
  n = 20
  cond1 = daub10_condition ( n )

  a = daub10 ( n )
  b = daub10_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB12
#
  title = 'DAUB12'
  n = 24
  cond1 = daub12_condition ( n )

  a = daub12 ( n )
  b = daub12_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DIAGONAL
#
  title = 'DIAGONAL'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  x, seed = r8vec_uniform_ab ( n, r8_lo, r8_hi, seed )
  cond1 = diagonal_condition ( n, x )

  a = diagonal ( n, n, x )
  b = diagonal_inverse ( n, x )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DIF2
#
  title = 'DIF2'
  n = 5
  cond1 = dif2_condition ( n )

  a = dif2 ( n, n )
  b = dif2_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DOWNSHIFT
#
  title = 'DOWNSHIFT'
  n = 5
  cond1 = downshift_condition ( n )

  a = downshift ( n )
  b = downshift_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  EXCHANGE
#
  title = 'EXCHANGE'
  n = 5
  cond1 = exchange_condition ( n )

  a = exchange ( n, n )
  b = exchange_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  FIBONACCI2
#
  title = 'FIBONACCI2'
  n = 5
  cond1 = fibonacci2_condition ( n )

  a = fibonacci2 ( n )
  b = fibonacci2_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  GFPP
#
  title = 'GFPP'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = gfpp_condition ( n, alpha )

  a = gfpp ( n, alpha )
  b = gfpp_inverse ( n, alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  GIVENS
#
  title = 'GIVENS'
  n = 5
  cond1 = givens_condition ( n )

  a = givens ( n, n )
  b = givens_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  HANKEL_N
#
  title = 'HANKEL_N'
  n = 5
  cond1 = hankel_n_condition ( n )

  a = hankel_n ( n )
  b = hankel_n_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  HARMAN
#
  title = 'HARMAN'
  n = 8
  cond1 = harman_condition ( )

  a = harman ( )
  b = harman_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  HARTLEY
#
  title = 'HARTLEY'
  n = 5
  cond1 = hartley_condition ( n )

  a = hartley ( n )
  b = hartley_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  IDENTITY
#
  title = 'IDENTITY'
  n = 5
  cond1 = identity_condition ( n )

  a = identity ( n, n )
  b = identity_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  ILL3
#
  title = 'ILL3'
  n = 3
  cond1 = ill3_condition ( )

  a = ill3 ( )
  b = ill3_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  JORDAN
#
  title = 'JORDAN'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = jordan_condition ( n, alpha )

  a = jordan ( n, n, alpha )
  b = jordan_inverse ( n, alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  KERSHAW
#
  title = 'KERSHAW'
  n = 4
  cond1 = kershaw_condition ( )

  a = kershaw ( )
  b = kershaw_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  LIETZKE
#
  title = 'LIETZKE'
  n = 5
  cond1 = lietzke_condition ( n )

  a = lietzke ( n )
  b = lietzke_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  MAXIJ
#
  title = 'MAXIJ'
  n = 5
  cond1 = maxij_condition ( n )

  a = maxij ( n, n )
  b = maxij_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  MINIJ
#
  title = 'MINIJ'
  n = 5
  cond1 = minij_condition ( n )

  a = minij ( n, n )
  b = minij_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  ORTH_SYMM
#
  title = 'ORTH_SYMM'
  n = 5
  cond1 = orth_symm_condition ( n )

  a = orth_symm ( n )
  b = orth_symm_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  OTO
#
  title = 'OTO'
  n = 5
  cond1 = oto_condition ( n )

  a = oto ( n, n )
  b = oto_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  PASCAL1
#
  title = 'PASCAL1'
  n = 5
  cond1 = pascal1_condition ( n )

  a = pascal1 ( n )
  b = pascal1_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  PASCAL3
#
  title = 'PASCAL3'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = pascal3_condition ( n, alpha )

  a = pascal3 ( n, alpha )
  b = pascal3_inverse ( n, alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  PEI
#
  title = 'PEI'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = pei_condition ( alpha, n )

  a = pei ( alpha, n )
  b = pei_inverse ( alpha, n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RODMAN
#
  title = 'RODMAN'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = rodman_condition ( n, alpha )

  a = rodman ( n, n, alpha )
  b = rodman_inverse ( n, alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RUTIS1
#
  title = 'RUTIS1'
  n = 4
  cond1 = rutis1_condition ( )

  a = rutis1 ( )
  b = rutis1_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RUTIS2
#
  title = 'RUTIS2'
  n = 4
  cond1 = rutis2_condition ( )

  a = rutis2 ( )
  b = rutis2_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RUTIS3
#
  title = 'RUTIS3'
  n = 4
  cond1 = rutis3_condition ( )

  a = rutis3 ( )
  b = rutis3_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RUTIS5
#
  title = 'RUTIS5'
  n = 4
  cond1 = rutis5_condition ( )

  a = rutis5 ( )
  b = rutis5_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SUMMATION
#
  title = 'SUMMATION'
  n = 5
  cond1 = summation_condition ( n )

  a = summation ( n, n )
  b = summation_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SWEET1
#
  title = 'SWEET1'
  n = 6
  cond1 = sweet1_condition ( )

  a = sweet1 ( )
  b = sweet1_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SWEET2
#
  title = 'SWEET2'
  n = 6
  cond1 = sweet2_condition ( )

  a = sweet2 ( )
  b = sweet2_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SWEET3
#
  title = 'SWEET3'
  n = 6
  cond1 = sweet3_condition ( )

  a = sweet3 ( )
  b = sweet3_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SWEET4
#
  title = 'SWEET4'
  n = 13
  cond1 = sweet4_condition ( )

  a = sweet4 ( )
  b = sweet4_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  TRI_UPPER
#
  title = 'TRI_UPPER'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = tri_upper_condition ( alpha, n )

  a = tri_upper ( alpha, n )
  b = tri_upper_inverse ( alpha, n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  UPSHIFT
#
  title = 'UPSHIFT'
  n = 5
  cond1 = upshift_condition ( n )

  a = upshift ( n )
  b = upshift_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  WILK03
#
  title = 'WILK03'
  n = 3
  cond1 = wilk03_condition ( )

  a = wilk03 ( )
  b = wilk03_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  WILK04
#
  title = 'WILK04'
  n = 4
  cond1 = wilk04_condition ( )

  a = wilk04 ( )
  b = wilk04_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  WILK05
#
  title = 'WILK05'
  n = 5
  cond1 = wilk05_condition ( )

  a = wilk05 ( )
  b = wilk05_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  WILSON
#
  title = 'WILSON'
  n = 4
  cond1 = wilson_condition ( )

  a = wilson ( )
  b = wilson_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  Terminate.
#
  print ''
  print 'TEST_CONDITION'
  print '  Normal end of execution.'

  return
예제 #19
0
def process_day(reader_fills,reader_orders,fill_row,order_row,fills_continue,orders_continue):
    time_format = '%m/%d/%y %I:%M:%S %p'
    fill_time = fill_row['timestamp']
    order_time = order_row['timestamp']

    # Initialize today so that can check each day against it
    # Stop processing when the day is over
    today = fill_time.date()

    # Initialize exchange object
    exch = exchange.exchange()
    
    # Fills that occur before first order of day are not valid
    # Skip and print error
    while fill_time < order_time and fill_time.date() == today:
        print "fill %s arrived before first order of day" % fill_row['timestamp']
        fill_row = reader_fills.next() 
        fill_time = dt.datetime.strptime(fill_row['timestamp'],time_format)
        
    # While today and not end of csv first try to process to exchange
    # Then read next line in fill/order file that is chronologically behind the other
    # run a basic data check and loop
    # read until one file ends or begin new day
    while fills_continue and orders_continue and fill_time.date() == today and order_time.date() == today:
        if order_time <= fill_time:
            try:
                exch.process_order(order_row)
            except:
                pass
            try:
                order_row = reader_orders.next()
                try:
                    order_row = od.order_basic_check(order_row)
                    if order_time < order_row['timestamp']:
                        order_time = order_row['timestamp']
                except:
                    pass
            except:
                print "end of orders"
                order_time = None
                orders_continue = False
        elif order_time > fill_time:
            try:
                exch.process_fill(fill_row)
            except:
                pass
            try:
                fill_row = reader_fills.next()
                try:
                    fill_row = od.fill_basic_check(fill_row)
                    if fill_time < fill_row['timestamp']:
                        fill_time = fill_row['timestamp']
                except:
                    pass
            except:
                print "end of fills"
                fill_time = None
                fills_continue = False

    # If order file terminated first loop, finish fill file
    while fills_continue and fill_time.date() == today:
        try:
            exch.process_fill(fill_row)
        except:
            pass
        try:
            fill_row = reader_fills.next()
            try:
                fill_row = od.fill_basic_check(fill_row)
                if fill_time < fill_row['timestamp']:
                    fill_time = fill_row['timestamp']
            except:
                pass
        except:
            print "end of fills"
            fill_time = None
            fills_continue = False

    # If fill file terminated first loop, finish order file
    while orders_continue and order_time.date() == today:
        try:
            exch.process_order(order_row)
        except:
            pass
        try:
            order_row = reader_orders.next()
            try:
                order_row = od.order_basic_check(order_row)
                if order_time < order_row['timestamp']:
                    order_time = order_row['timestamp']
            except:
                pass
        except:
            print "end of orders"
            order_time = None
            orders_continue = False

    # Print ordres still open at the end of day
    exch.check_all_close_eod()

    # Return csv handler along with continuation conditions and next row as a tuple
    # Need to return the row because the the csvreader.next() returns row and increments 
    return (reader_fills,reader_orders,fill_row,order_row,fills_continue,orders_continue)
예제 #20
0
def process_day(reader_fills,reader_orders,fill_row,order_row,fills_continue,orders_continue):
    time_format = '%m/%d/%y %I:%M:%S %p'
    fill_time = fill_row['timestamp']
    order_time = order_row['timestamp']
    today = fill_time.date()

    exch = exchange.exchange()
    
    # Fills that occur before first order of day are not valid
    while fill_time < order_time:
        print "fill %s arrived before first order of day" % fill_row['timestamp']
        fill_row = reader_fills.next() 
        fill_time = dt.datetime.strptime(fill_row['timestamp'],time_format)
        

    while fills_continue and orders_continue and fill_time.date() == today and order_time.date() == today:
        # read next row based on which row is behind the other
        if order_time <= fill_time:
            try:
                exch.process_order(order_row)
            except Exception as msg:
                print msg
            try:
                order_row = reader_orders.next()
#                print order_row['id']                
                try:
                    order_row = od.order_basic_check(order_row)
                    order_time = order_row['timestamp']
                except Exception as msg:
                    print msg            
#                print order_row['id']
            except:
                print "end of orders"
                order_time = None
                orders_continue = False
        elif order_time > fill_time:
            exch.process_fill(fill_row)
            try:
                fill_row = reader_fills.next()
                try:
                    fill_row = od.fill_basic_check(fill_row)
                    fill_time = fill_row['timestamp']
                except Exception as msg:
                    print msg
#                print fill_row['id']
            except:
                print "end of fills"
                fill_time = None
                fills_continue = False
    
    # Now finish the longer list
    while fills_continue and fill_time.date() == today:
        exch.process_fill(fill_row)        
        try:
            fill_row = reader_fills.next()
            try:
                fill_row = od.fill_basic_check(fill_row)
                fill_time = fill_row['timestamp']
            except Exception as msg:
                print msg
#            print fill_row['id']            
        except:
            print "end of fills"
            fill_time = None
            fills_continue = False        
    
    while orders_continue and order_time.date() == today:
        exch.process_order(order_row)        
        try:
            order_row = reader_orders.next()
            try:
                order_row = od.order_basic_check(order_row)
                order_time = order_row['timestamp']
            except Exception as msg:
                print msg
#            print order_row['id']            
        except:
            print "end of orders"
            order_time = None
            orders_continue = False

    # Check to see that the order log is esmpty at the end of a day
    exch.check_all_close_eod()

    return (reader_fills,reader_orders,fill_row,order_row,fills_continue,orders_continue)