001 package com.croftsoft.apps.insight;
002
003 public class Matrix_Array {
004 //////////////////////////////////////////////////////////////////////
005 // Matrix_Array.java v0.0 (C) Copyright 1996 David Wallace Croft.
006 // 1996-09-02
007 //////////////////////////////////////////////////////////////////////
008
009 Matrix [ ] m; // matrices
010
011 public Matrix_Array ( int matrices_count ) {
012 //////////////////////////////////////////////////////////////////////
013 // Constructor method
014 //////////////////////////////////////////////////////////////////////
015 this.m = new Matrix [ matrices_count ];
016 for ( int index_matrix = 0;
017 index_matrix < matrices_count;
018 index_matrix++ ) {
019 this.m [ index_matrix ] = new Matrix ( 1, 1 );
020 }
021 }
022
023 public Matrix_Array ( Matrix [ ] matrices_array ) {
024 //////////////////////////////////////////////////////////////////////
025 // Constructor method
026 //////////////////////////////////////////////////////////////////////
027 this.m = new Matrix [ matrices_array.length ];
028 for ( int index_matrix = 0;
029 index_matrix < matrices_array.length;
030 index_matrix++ ) {
031 this.m [ index_matrix ]
032 = new Matrix ( matrices_array [ index_matrix ] );
033 }
034 }
035
036 public Matrix_Array ( Matrix_Array template ) {
037 //////////////////////////////////////////////////////////////////////
038 // Constructor method
039 //////////////////////////////////////////////////////////////////////
040 this.m = new Matrix [ template.m.length ];
041 for ( int index_matrix = 0;
042 index_matrix < template.m.length;
043 index_matrix++ ) {
044 this.m [ index_matrix ]
045 = new Matrix ( template.m [ index_matrix ] );
046 }
047 }
048
049 public Matrix_Array add ( Matrix_Array addend ) {
050 //////////////////////////////////////////////////////////////////////
051 if ( this.m.length != addend.m.length ) {
052 throw new ArrayIndexOutOfBoundsException (
053 "Matrix_Array.add ( Matrix_Array ): arrays mismatched" );
054 }
055 Matrix_Array new_matrix_array = new Matrix_Array ( this );
056 for ( int index_matrix = 0;
057 index_matrix < this.m.length;
058 index_matrix++ ) {
059 new_matrix_array.m [ index_matrix ]
060 = this.m [ index_matrix ].add ( addend.m [ index_matrix ] );
061 }
062 return new_matrix_array;
063 }
064
065 public Matrix_Array multiply ( double factor ) {
066 //////////////////////////////////////////////////////////////////////
067 Matrix_Array new_matrix_array = new Matrix_Array ( this );
068 for ( int index_matrix = 0;
069 index_matrix < this.m.length;
070 index_matrix++ ) {
071 new_matrix_array.m [ index_matrix ]
072 = this.m [ index_matrix ].multiply ( factor );
073 }
074 return new_matrix_array;
075 }
076
077 //////////////////////////////////////////////////////////////////////
078 //////////////////////////////////////////////////////////////////////
079 }