mirror of
				https://github.com/gonum/gonum.git
				synced 2025-10-31 18:42:45 +08:00 
			
		
		
		
	lapack: rename LeftEV and RightEV job constants
This commit is contained in:
		 Vladimir Chalupecky
					Vladimir Chalupecky
				
			
				
					committed by
					
						 Vladimír Chalupecký
						Vladimír Chalupecký
					
				
			
			
				
	
			
			
			 Vladimír Chalupecký
						Vladimír Chalupecký
					
				
			
						parent
						
							de667f08e7
						
					
				
				
					commit
					a6f3f37374
				
			| @@ -36,9 +36,10 @@ import ( | |||||||
| // where i is the imaginary unit. The computed eigenvectors are normalized to | // where i is the imaginary unit. The computed eigenvectors are normalized to | ||||||
| // have Euclidean norm equal to 1 and largest component real. | // have Euclidean norm equal to 1 and largest component real. | ||||||
| // | // | ||||||
| // Left eigenvectors will be computed only if jobvl == lapack.ComputeLeftEV, | // Left eigenvectors will be computed only if jobvl == lapack.LeftEVCompute, | ||||||
| // otherwise jobvl must be lapack.None. Right eigenvectors will be computed | // otherwise jobvl must be lapack.LeftEVNone. | ||||||
| // only if jobvr == lapack.ComputeRightEV, otherwise jobvr must be lapack.None. | // Right eigenvectors will be computed only if jobvr == lapack.RightEVCompute, | ||||||
|  | // otherwise jobvr must be lapack.RightEVNone. | ||||||
| // For other values of jobvl and jobvr Dgeev will panic. | // For other values of jobvl and jobvr Dgeev will panic. | ||||||
| // | // | ||||||
| // wr and wi contain the real and imaginary parts, respectively, of the computed | // wr and wi contain the real and imaginary parts, respectively, of the computed | ||||||
| @@ -64,17 +65,17 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob | |||||||
| 	switch jobvl { | 	switch jobvl { | ||||||
| 	default: | 	default: | ||||||
| 		panic("lapack: invalid LeftEVJob") | 		panic("lapack: invalid LeftEVJob") | ||||||
| 	case lapack.ComputeLeftEV: | 	case lapack.LeftEVCompute: | ||||||
| 		wantvl = true | 		wantvl = true | ||||||
| 	case lapack.None: | 	case lapack.LeftEVNone: | ||||||
| 	} | 	} | ||||||
| 	var wantvr bool | 	var wantvr bool | ||||||
| 	switch jobvr { | 	switch jobvr { | ||||||
| 	default: | 	default: | ||||||
| 		panic("lapack: invalid RightEVJob") | 		panic("lapack: invalid RightEVJob") | ||||||
| 	case lapack.ComputeRightEV: | 	case lapack.RightEVCompute: | ||||||
| 		wantvr = true | 		wantvr = true | ||||||
| 	case lapack.None: | 	case lapack.RightEVNone: | ||||||
| 	} | 	} | ||||||
| 	switch { | 	switch { | ||||||
| 	case n < 0: | 	case n < 0: | ||||||
|   | |||||||
| @@ -145,16 +145,20 @@ const ( | |||||||
| 	EVNone    EVJob = 'N' // Eigenvectors are not computed. | 	EVNone    EVJob = 'N' // Eigenvectors are not computed. | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Job types for computation of eigenvectors. | // LeftEVJob specifies whether left eigenvectors are computed in Dgeev. | ||||||
| type ( | type LeftEVJob byte | ||||||
| 	LeftEVJob  byte |  | ||||||
| 	RightEVJob byte | const ( | ||||||
|  | 	LeftEVCompute LeftEVJob = 'V' // Left eigenvectors are computed. | ||||||
|  | 	LeftEVNone    LeftEVJob = 'N' // Left eigenvectors are not computed. | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Job constants for computation of eigenvectors. | // RightEVJob specifies whether right eigenvectors are computed in Dgeev. | ||||||
|  | type RightEVJob byte | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| 	ComputeLeftEV  LeftEVJob  = 'V' // Compute left eigenvectors. | 	RightEVCompute RightEVJob = 'V' // Right eigenvectors are computed. | ||||||
| 	ComputeRightEV RightEVJob = 'V' // Compute right eigenvectors. | 	RightEVNone    RightEVJob = 'N' // Right eigenvectors are not computed. | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // BalanceJob specifies matrix balancing operation. | // BalanceJob specifies matrix balancing operation. | ||||||
|   | |||||||
| @@ -515,10 +515,10 @@ func Trtrs(trans blas.Transpose, a blas64.Triangular, b blas64.General) (ok bool | |||||||
| // where i is the imaginary unit. The computed eigenvectors are normalized to | // where i is the imaginary unit. The computed eigenvectors are normalized to | ||||||
| // have Euclidean norm equal to 1 and largest component real. | // have Euclidean norm equal to 1 and largest component real. | ||||||
| // | // | ||||||
| // Left eigenvectors will be computed only if jobvl == lapack.ComputeLeftEV, | // Left eigenvectors will be computed only if jobvl == lapack.LeftEVCompute, | ||||||
| // otherwise jobvl must be lapack.None. | // otherwise jobvl must be lapack.LeftEVNone. | ||||||
| // Right eigenvectors will be computed only if jobvr == lapack.ComputeRightEV, | // Right eigenvectors will be computed only if jobvr == lapack.RightEVCompute, | ||||||
| // otherwise jobvr must be lapack.None. | // otherwise jobvr must be lapack.RightEVNone. | ||||||
| // For other values of jobvl and jobvr Geev will panic. | // For other values of jobvl and jobvr Geev will panic. | ||||||
| // | // | ||||||
| // On return, wr and wi will contain the real and imaginary parts, respectively, | // On return, wr and wi will contain the real and imaginary parts, respectively, | ||||||
| @@ -544,10 +544,10 @@ func Geev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob, a blas64.General, wr, | |||||||
| 	if a.Cols != n { | 	if a.Cols != n { | ||||||
| 		panic("lapack64: matrix not square") | 		panic("lapack64: matrix not square") | ||||||
| 	} | 	} | ||||||
| 	if jobvl == lapack.ComputeLeftEV && (vl.Rows != n || vl.Cols != n) { | 	if jobvl == lapack.LeftEVCompute && (vl.Rows != n || vl.Cols != n) { | ||||||
| 		panic("lapack64: bad size of VL") | 		panic("lapack64: bad size of VL") | ||||||
| 	} | 	} | ||||||
| 	if jobvr == lapack.ComputeRightEV && (vr.Rows != n || vr.Cols != n) { | 	if jobvr == lapack.RightEVCompute && (vr.Rows != n || vr.Cols != n) { | ||||||
| 		panic("lapack64: bad size of VR") | 		panic("lapack64: bad size of VR") | ||||||
| 	} | 	} | ||||||
| 	return lapack64.Dgeev(jobvl, jobvr, n, a.Data, a.Stride, wr, wi, vl.Data, vl.Stride, vr.Data, vr.Stride, work, lwork) | 	return lapack64.Dgeev(jobvl, jobvr, n, a.Data, a.Stride, wr, wi, vl.Data, vl.Stride, vr.Data, vr.Stride, work, lwork) | ||||||
|   | |||||||
| @@ -475,8 +475,8 @@ func DgeevTest(t *testing.T, impl Dgeever) { | |||||||
| 			evWant: Zero(100).Eigenvalues(), | 			evWant: Zero(100).Eigenvalues(), | ||||||
| 		}, | 		}, | ||||||
| 	} { | 	} { | ||||||
| 		for _, jobvl := range []lapack.LeftEVJob{lapack.ComputeLeftEV, lapack.None} { | 		for _, jobvl := range []lapack.LeftEVJob{lapack.LeftEVCompute, lapack.LeftEVNone} { | ||||||
| 			for _, jobvr := range []lapack.RightEVJob{lapack.ComputeRightEV, lapack.None} { | 			for _, jobvr := range []lapack.RightEVJob{lapack.RightEVCompute, lapack.RightEVNone} { | ||||||
| 				for _, extra := range []int{0, 11} { | 				for _, extra := range []int{0, 11} { | ||||||
| 					for _, wl := range []worklen{minimumWork, mediumWork, optimumWork} { | 					for _, wl := range []worklen{minimumWork, mediumWork, optimumWork} { | ||||||
| 						testDgeev(t, impl, strconv.Itoa(i), test, jobvl, jobvr, extra, wl) | 						testDgeev(t, impl, strconv.Itoa(i), test, jobvl, jobvr, extra, wl) | ||||||
| @@ -487,8 +487,8 @@ func DgeevTest(t *testing.T, impl Dgeever) { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for _, n := range []int{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 50, 51, 100, 101} { | 	for _, n := range []int{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 50, 51, 100, 101} { | ||||||
| 		for _, jobvl := range []lapack.LeftEVJob{lapack.ComputeLeftEV, lapack.None} { | 		for _, jobvl := range []lapack.LeftEVJob{lapack.LeftEVCompute, lapack.LeftEVNone} { | ||||||
| 			for _, jobvr := range []lapack.RightEVJob{lapack.ComputeRightEV, lapack.None} { | 			for _, jobvr := range []lapack.RightEVJob{lapack.RightEVCompute, lapack.RightEVNone} { | ||||||
| 				for cas := 0; cas < 10; cas++ { | 				for cas := 0; cas < 10; cas++ { | ||||||
| 					// Create a block diagonal matrix with | 					// Create a block diagonal matrix with | ||||||
| 					// random eigenvalues of random multiplicity. | 					// random eigenvalues of random multiplicity. | ||||||
| @@ -557,12 +557,12 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa | |||||||
| 	n := a.Rows | 	n := a.Rows | ||||||
|  |  | ||||||
| 	var vl blas64.General | 	var vl blas64.General | ||||||
| 	if jobvl == lapack.ComputeLeftEV { | 	if jobvl == lapack.LeftEVCompute { | ||||||
| 		vl = nanGeneral(n, n, n) | 		vl = nanGeneral(n, n, n) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	var vr blas64.General | 	var vr blas64.General | ||||||
| 	if jobvr == lapack.ComputeRightEV { | 	if jobvr == lapack.RightEVCompute { | ||||||
| 		vr = nanGeneral(n, n, n) | 		vr = nanGeneral(n, n, n) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -572,7 +572,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa | |||||||
| 	var lwork int | 	var lwork int | ||||||
| 	switch wl { | 	switch wl { | ||||||
| 	case minimumWork: | 	case minimumWork: | ||||||
| 		if jobvl == lapack.ComputeLeftEV || jobvr == lapack.ComputeRightEV { | 		if jobvl == lapack.LeftEVCompute || jobvr == lapack.RightEVCompute { | ||||||
| 			lwork = max(1, 4*n) | 			lwork = max(1, 4*n) | ||||||
| 		} else { | 		} else { | ||||||
| 			lwork = max(1, 3*n) | 			lwork = max(1, 3*n) | ||||||
| @@ -580,7 +580,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa | |||||||
| 	case mediumWork: | 	case mediumWork: | ||||||
| 		work := make([]float64, 1) | 		work := make([]float64, 1) | ||||||
| 		impl.Dgeev(jobvl, jobvr, n, nil, 1, nil, nil, nil, 1, nil, 1, work, -1) | 		impl.Dgeev(jobvl, jobvr, n, nil, 1, nil, nil, nil, 1, nil, 1, work, -1) | ||||||
| 		if jobvl == lapack.ComputeLeftEV || jobvr == lapack.ComputeRightEV { | 		if jobvl == lapack.LeftEVCompute || jobvr == lapack.RightEVCompute { | ||||||
| 			lwork = (int(work[0]) + 4*n) / 2 | 			lwork = (int(work[0]) + 4*n) / 2 | ||||||
| 		} else { | 		} else { | ||||||
| 			lwork = (int(work[0]) + 3*n) / 2 | 			lwork = (int(work[0]) + 3*n) / 2 | ||||||
| @@ -644,7 +644,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if first > 0 || (jobvl == lapack.None && jobvr == lapack.None) { | 	if first > 0 || (jobvl == lapack.LeftEVNone && jobvr == lapack.RightEVNone) { | ||||||
| 		// No eigenvectors have been computed. | 		// No eigenvectors have been computed. | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| @@ -653,7 +653,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa | |||||||
| 	// to the computed eigenvalues. | 	// to the computed eigenvalues. | ||||||
| 	for k := 0; k < n; { | 	for k := 0; k < n; { | ||||||
| 		if wi[k] == 0 { | 		if wi[k] == 0 { | ||||||
| 			if jobvl == lapack.ComputeLeftEV { | 			if jobvl == lapack.LeftEVCompute { | ||||||
| 				ev := columnOf(vl, k) | 				ev := columnOf(vl, k) | ||||||
| 				if !isLeftEigenvectorOf(test.a, ev, nil, complex(wr[k], 0), vecTol) { | 				if !isLeftEigenvectorOf(test.a, ev, nil, complex(wr[k], 0), vecTol) { | ||||||
| 					t.Errorf("%v: VL[:,%v] is not left real eigenvector", | 					t.Errorf("%v: VL[:,%v] is not left real eigenvector", | ||||||
| @@ -666,7 +666,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa | |||||||
| 						prefix, k, norm) | 						prefix, k, norm) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			if jobvr == lapack.ComputeRightEV { | 			if jobvr == lapack.RightEVCompute { | ||||||
| 				ev := columnOf(vr, k) | 				ev := columnOf(vr, k) | ||||||
| 				if !isRightEigenvectorOf(test.a, ev, nil, complex(wr[k], 0), vecTol) { | 				if !isRightEigenvectorOf(test.a, ev, nil, complex(wr[k], 0), vecTol) { | ||||||
| 					t.Errorf("%v: VR[:,%v] is not right real eigenvector", | 					t.Errorf("%v: VR[:,%v] is not right real eigenvector", | ||||||
| @@ -681,7 +681,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa | |||||||
| 			} | 			} | ||||||
| 			k++ | 			k++ | ||||||
| 		} else { | 		} else { | ||||||
| 			if jobvl == lapack.ComputeLeftEV { | 			if jobvl == lapack.LeftEVCompute { | ||||||
| 				evre := columnOf(vl, k) | 				evre := columnOf(vl, k) | ||||||
| 				evim := columnOf(vl, k+1) | 				evim := columnOf(vl, k+1) | ||||||
| 				if !isLeftEigenvectorOf(test.a, evre, evim, complex(wr[k], wi[k]), vecTol) { | 				if !isLeftEigenvectorOf(test.a, evre, evim, complex(wr[k], wi[k]), vecTol) { | ||||||
| @@ -700,7 +700,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa | |||||||
| 						prefix, k, norm) | 						prefix, k, norm) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			if jobvr == lapack.ComputeRightEV { | 			if jobvr == lapack.RightEVCompute { | ||||||
| 				evre := columnOf(vr, k) | 				evre := columnOf(vr, k) | ||||||
| 				evim := columnOf(vr, k+1) | 				evim := columnOf(vr, k+1) | ||||||
| 				if !isRightEigenvectorOf(test.a, evre, evim, complex(wr[k], wi[k]), vecTol) { | 				if !isRightEigenvectorOf(test.a, evre, evim, complex(wr[k], wi[k]), vecTol) { | ||||||
|   | |||||||
| @@ -46,14 +46,14 @@ func DgeevBenchmark(b *testing.B, impl Dgeever) { | |||||||
| 		wr := make([]float64, n) | 		wr := make([]float64, n) | ||||||
| 		wi := make([]float64, n) | 		wi := make([]float64, n) | ||||||
| 		work := make([]float64, 1) | 		work := make([]float64, 1) | ||||||
| 		impl.Dgeev(lapack.ComputeLeftEV, lapack.ComputeRightEV, n, nil, n, nil, nil, nil, n, nil, n, work, -1) | 		impl.Dgeev(lapack.LeftEVCompute, lapack.RightEVCompute, n, nil, n, nil, nil, nil, n, nil, n, work, -1) | ||||||
| 		work = make([]float64, int(work[0])) | 		work = make([]float64, int(work[0])) | ||||||
| 		b.Run(bm.name, func(b *testing.B) { | 		b.Run(bm.name, func(b *testing.B) { | ||||||
| 			for i := 0; i < b.N; i++ { | 			for i := 0; i < b.N; i++ { | ||||||
| 				b.StopTimer() | 				b.StopTimer() | ||||||
| 				copyGeneral(a, bm.a) | 				copyGeneral(a, bm.a) | ||||||
| 				b.StartTimer() | 				b.StartTimer() | ||||||
| 				impl.Dgeev(lapack.ComputeLeftEV, lapack.ComputeRightEV, n, a.Data, a.Stride, wr, wi, | 				impl.Dgeev(lapack.LeftEVCompute, lapack.RightEVCompute, n, a.Data, a.Stride, wr, wi, | ||||||
| 					vl.Data, vl.Stride, vr.Data, vr.Stride, work, len(work)) | 					vl.Data, vl.Stride, vr.Data, vr.Stride, work, len(work)) | ||||||
| 			} | 			} | ||||||
| 			resultGeneral = a | 			resultGeneral = a | ||||||
|   | |||||||
| @@ -154,15 +154,15 @@ func (e *Eigen) Factorize(a Matrix, left, right bool) (ok bool) { | |||||||
| 	sd.Clone(a) | 	sd.Clone(a) | ||||||
|  |  | ||||||
| 	var vl, vr Dense | 	var vl, vr Dense | ||||||
| 	var jobvl lapack.LeftEVJob = lapack.None | 	jobvl := lapack.LeftEVNone | ||||||
| 	var jobvr lapack.RightEVJob = lapack.None | 	jobvr := lapack.RightEVNone | ||||||
| 	if left { | 	if left { | ||||||
| 		vl = *NewDense(r, r, nil) | 		vl = *NewDense(r, r, nil) | ||||||
| 		jobvl = lapack.ComputeLeftEV | 		jobvl = lapack.LeftEVCompute | ||||||
| 	} | 	} | ||||||
| 	if right { | 	if right { | ||||||
| 		vr = *NewDense(c, c, nil) | 		vr = *NewDense(c, c, nil) | ||||||
| 		jobvr = lapack.ComputeRightEV | 		jobvr = lapack.RightEVCompute | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	wr := getFloats(c, false) | 	wr := getFloats(c, false) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user