Python(パイソン) ,ソースプログラムリスト あり ,プログラム作ってみた ,numpy使用した行列のクラス
Python(パイソン) プログラム作ってみた インデックス へ
-----
2024.8.19 presented in [note] ( //note.com/runningWater/ )
2024.8.24 rewritten
----------
1 はじめに
これ以降に記述されている内容は、このようなコンピューター・プログラムを制作した、というような事を、ただ、述べているに過ぎない。
以下の記述を読んだ人が、それを単に参考にする、というのであれば、問題は無いと、思われる。
しかし、記述されている内容に沿って、その人が、そこに記されているのと同様の制作や作業を行った際に、その制作、作業、コンピューターの作動の結果、使用されたコンピューター等、様々な方面において、何らかの問題が発生しない、という保証は、全くない。
その制作、作業、コンピューターの作動の結果、その人や、その人が所属している組織、その人が使用した様々な機器、インフラストラクチャー等の、身の上にどのような事が起ころうとも、私は一切、責任を負わない。
このプログラムは、Python(パイソン) 言語を使って、記述されている。
----------
2 どんなものを作ったのか
クラスを使って、生成されたインスタンスの中に、行列を埋め込んでおく
、というような形にしておくと、これから先、なにかと好都合なのでは、と、思い、このプログラムを作ってみた。
行列を使う時には、[numpy]を使わないでやる、のよりも、[numpy]を使ってやる、方が、どうも、処理速度の点で有利だ、ということのようなので、[numpy]を使ってやることにした。
----------
3 プログラムの内容
下記のような、1個のモジュールを、作ってみた。
===============
ファイル名 [MatrixUsingNUMPY.py]
----------
import numpy as NUMPY
#===========================================
class MatrixUsingNUMPY :
CV_CLASS_NAME = "MatrixUsingNUMPY"
#------------------------------------------------------------
# definition of constructer
def __init__( self
, arg_requester_module
, arg_requester_function
, arg_list_tow_Dimensional_matrix_set_values_definition
) :
methode_name = "constructer"
print ( "==================================" )
print ( "Enter into , Class = " + MatrixUsingNUMPY.CV_CLASS_NAME
+ " , methode = " + methode_name )
print ( " arg_requester_module = " + arg_requester_module
+ " , arg_requester_function = " + arg_requester_function )
print ( "==================================" )
self.iv_matrix_using_NUMPY_contained_in_this_instance \
= NUMPY.array ( \
arg_list_tow_Dimensional_matrix_set_values_definition \
)
self.display_content_of_matrix ( )
print ( "==================================" )
print ( "Exit from , Class = " + MatrixUsingNUMPY.CV_CLASS_NAME
+ " , methode = " + methode_name )
print ( " arg_requester_module = " + arg_requester_module
+ " , arg_requester_function = " + arg_requester_function )
print ( "==================================" )
#------------------------------------------------------------
def display_content_of_matrix ( self \
) :
methode_name = "display_content_of_matrix"
print ( "==================================" )
print ( "Class = " + MatrixUsingNUMPY.CV_CLASS_NAME
+ " , methode = " + methode_name )
print ( "==================================" )
print ( self.iv_matrix_using_NUMPY_contained_in_this_instance )
print ( "==================================" )
#------------------------------------------------------------
def get_matrix_using_NUMPY_contained_in_this_instance ( \
self \
) :
methode_name = "get_matrix_using_NUMPY_contained_in_this_instance"
return self.iv_matrix_using_NUMPY_contained_in_this_instance
#-----------------------------------------
# Test Run
#requester_module = "___"
#requester_function = "Test Run"
#methode_name = "Test Run"
#print ( "==================================" )
#print ( "==== Test Run ==============================" )
#print ( "==================================" )
#print ( " " )
#print ( "==================================" )
#print ( "Enter into , Class = " + MatrixUsingNUMPY.CV_CLASS_NAME
# + " , methode = " + methode_name )
#print ( "==================================" )
#print ( "NUMPY.__version__ = " , NUMPY.__version__ )
#matrix_definiotn_A = [ [ 0 , 1 , 2 ] , [ 3 , 4 , 5 ] , [ 6 , 7 , 8 ] ]
#matrix_definiotn_B = [ [ 6 , 7 , 8 ] , [ 3 , 4 , 5 ] , [ 0 , 1 , 2 ] ]
#ins_MatrixUsingNUMPY_A = MatrixUsingNUMPY ( \
# requester_module
# , requester_function
# , matrix_definiotn_A
# )
#ins_MatrixUsingNUMPY_A \
# .display_content_of_matrix ( )
#print ( "*******************************" )
#print ( "*******************************" )
#ins_MatrixUsingNUMPY_B = MatrixUsingNUMPY ( \
# requester_module
# , requester_function
# , matrix_definiotn_B
# )
#ins_MatrixUsingNUMPY_B \
# .display_content_of_matrix ( )
#print ( "*******************************" )
#print ( "*******************************" )
#matrix_A = \
# ins_MatrixUsingNUMPY_A \
# .get_matrix_using_NUMPY_contained_in_this_instance ( )
#matrix_B = \
# ins_MatrixUsingNUMPY_B \
# .get_matrix_using_NUMPY_contained_in_this_instance ( )
#matrixUsingNUMPY_new_made = \
# NUMPY.matmul ( \
# matrix_A
# , matrix_B )
#print ( "matrixUsingNUMPY_new_made = " )
#print ( matrixUsingNUMPY_new_made )
----------