Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ndarray_linalg::lapack alias, make lax submodule private #242

Merged
merged 2 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions lax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,22 @@ extern crate openblas_src as _src;
#[cfg(any(feature = "netlib-system", feature = "netlib-static"))]
extern crate netlib_src as _src;

pub mod cholesky;
pub mod eig;
pub mod eigh;
pub mod error;
pub mod layout;
pub mod least_squares;
pub mod opnorm;
pub mod qr;
pub mod rcond;
pub mod solve;
pub mod solveh;
pub mod svd;
pub mod svddc;
pub mod triangular;
pub mod tridiagonal;

mod cholesky;
mod eig;
mod eigh;
mod least_squares;
mod opnorm;
mod qr;
mod rcond;
mod solve;
mod solveh;
mod svd;
mod svddc;
mod triangular;
mod tridiagonal;

pub use self::cholesky::*;
pub use self::eig::*;
Expand Down Expand Up @@ -159,7 +160,7 @@ pub enum NormType {
}

impl NormType {
pub(crate) fn transpose(self) -> Self {
pub fn transpose(self) -> Self {
match self {
NormType::One => NormType::Infinity,
NormType::Infinity => NormType::One,
Expand Down
3 changes: 1 addition & 2 deletions lax/src/opnorm.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
//! Operator norms of matrices

use super::NormType;
use crate::layout::MatrixLayout;
use cauchy::*;
use num_traits::Zero;

pub use super::NormType;

pub trait OperatorNorm_: Scalar {
fn opnorm(t: NormType, l: MatrixLayout, a: &[Self]) -> Self::Real;
}
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/src/cholesky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use crate::layout::*;
use crate::triangular::IntoTriangular;
use crate::types::*;

pub use crate::lapack::UPLO;
pub use lax::UPLO;

/// Cholesky decomposition of Hermitian (or real symmetric) positive definite matrix
pub struct CholeskyFactorized<S: Data> {
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/src/convert.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! utilities for convert array

use lax::UPLO;
use ndarray::*;

use super::error::*;
use super::lapack::UPLO;
use super::layout::*;
use super::types::*;

Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub enum LinalgError {

/// LAPACK subroutine returns non-zero code
#[error(transparent)]
Lapack(#[from] lapack::error::Error),
Lapack(#[from] lax::error::Error),

/// Strides of the array is not supported
#[error("invalid stride: s0={}, s1={}", s0, s1)]
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use super::error::*;
use ndarray::*;

pub use lapack::layout::MatrixLayout;
pub use lax::layout::MatrixLayout;

pub trait AllocatedArray {
type Elem;
Expand Down
4 changes: 2 additions & 2 deletions ndarray-linalg/src/least_squares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
//! // `a` and `b` have been moved, no longer valid
//! ```

use lax::*;
use ndarray::*;

use crate::error::*;
use crate::lapack::least_squares::*;
use crate::layout::*;
use crate::types::*;

Expand Down Expand Up @@ -253,7 +253,7 @@ where
/// valid representation for `ArrayBase`.
impl<E, D> LeastSquaresSvdInPlace<D, E, Ix1> for ArrayBase<D, Ix2>
where
E: Scalar + Lapack + LeastSquaresSvdDivideConquer_,
E: Scalar + Lapack,
D: DataMut<Elem = E>,
{
/// Solve a least squares problem of the form `Ax = rhs`
Expand Down
1 change: 0 additions & 1 deletion ndarray-linalg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

#[macro_use]
extern crate ndarray;
extern crate lax as lapack;

pub mod assert;
pub mod cholesky;
Expand Down
4 changes: 3 additions & 1 deletion ndarray-linalg/src/lobpcg/eig.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use super::lobpcg::{lobpcg, LobpcgResult, Order};
use crate::{generate, Lapack, Scalar};
use crate::{generate, Scalar};
use lax::Lapack;

///! Implements truncated eigenvalue decomposition
///
use ndarray::prelude::*;
Expand Down
5 changes: 3 additions & 2 deletions ndarray-linalg/src/lobpcg/lobpcg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
///which can be used as a solver for large symmetric positive definite eigenproblems.
use crate::error::{LinalgError, Result};
use crate::{cholesky::*, close_l2, eigh::*, norm::*, triangular::*};
use crate::{Lapack, Scalar};
use cauchy::Scalar;
use lax::Lapack;
use ndarray::prelude::*;
use ndarray::{Data, OwnedRepr, ScalarOperand};
use num_traits::{Float, NumCast};
Expand Down Expand Up @@ -338,7 +339,7 @@ pub fn lobpcg<
let result = p_ap
.as_ref()
.ok_or(LinalgError::Lapack(
lapack::error::Error::LapackComputationalFailure { return_code: 1 },
lax::error::Error::LapackComputationalFailure { return_code: 1 },
))
.and_then(|(active_p, active_ap)| {
let xap = x.t().dot(active_ap);
Expand Down
4 changes: 3 additions & 1 deletion ndarray-linalg/src/lobpcg/svd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
///! This module computes the k largest/smallest singular values/vectors for a dense matrix.
use super::lobpcg::{lobpcg, LobpcgResult, Order};
use crate::error::Result;
use crate::{generate, Lapack, Scalar};
use crate::generate;
use cauchy::Scalar;
use lax::Lapack;
use ndarray::prelude::*;
use ndarray::ScalarOperand;
use num_traits::{Float, NumCast};
Expand Down
4 changes: 2 additions & 2 deletions ndarray-linalg/src/opnorm.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! Operator norm

use lax::Tridiagonal;
use ndarray::*;

use crate::convert::*;
use crate::error::*;
use crate::layout::*;
use crate::tridiagonal::Tridiagonal;
use crate::types::*;

pub use crate::lapack::NormType;
pub use lax::NormType;

/// Operator norm using `*lange` LAPACK routines
///
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/src/qr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::layout::*;
use crate::triangular::*;
use crate::types::*;

pub use crate::lapack::UPLO;
pub use lax::UPLO;

/// QR decomposition for matrix reference
///
Expand Down
6 changes: 3 additions & 3 deletions ndarray-linalg/src/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use crate::layout::*;
use crate::opnorm::OperationNorm;
use crate::types::*;

pub use crate::lapack::{Pivot, Transpose};
pub use lax::{Pivot, Transpose};

/// An interface for solving systems of linear equations.
///
Expand Down Expand Up @@ -468,7 +468,7 @@ where
self.ensure_square()?;
match self.factorize() {
Ok(fac) => fac.sln_det(),
Err(LinalgError::Lapack(e)) if matches!(e, lapack::error::Error::LapackComputationalFailure {..}) =>
Err(LinalgError::Lapack(e)) if matches!(e, lax::error::Error::LapackComputationalFailure {..}) =>
{
// The determinant is zero.
Ok((A::zero(), A::Real::neg_infinity()))
Expand All @@ -487,7 +487,7 @@ where
self.ensure_square()?;
match self.factorize_into() {
Ok(fac) => fac.sln_det_into(),
Err(LinalgError::Lapack(e)) if matches!(e, lapack::error::Error::LapackComputationalFailure { .. }) =>
Err(LinalgError::Lapack(e)) if matches!(e, lax::error::Error::LapackComputationalFailure { .. }) =>
{
// The determinant is zero.
Ok((A::zero(), A::Real::neg_infinity()))
Expand Down
6 changes: 3 additions & 3 deletions ndarray-linalg/src/solveh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use crate::error::*;
use crate::layout::*;
use crate::types::*;

pub use crate::lapack::{Pivot, UPLO};
pub use lax::{Pivot, UPLO};

/// An interface for solving systems of Hermitian (or real symmetric) linear equations.
///
Expand Down Expand Up @@ -426,7 +426,7 @@ where
fn sln_deth(&self) -> Result<(A::Real, A::Real)> {
match self.factorizeh() {
Ok(fac) => Ok(fac.sln_deth()),
Err(LinalgError::Lapack(e)) if matches!(e, lapack::error::Error::LapackComputationalFailure {..}) =>
Err(LinalgError::Lapack(e)) if matches!(e, lax::error::Error::LapackComputationalFailure {..}) =>
{
// Determinant is zero.
Ok((A::Real::zero(), A::Real::neg_infinity()))
Expand All @@ -451,7 +451,7 @@ where
fn sln_deth_into(self) -> Result<(A::Real, A::Real)> {
match self.factorizeh_into() {
Ok(fac) => Ok(fac.sln_deth_into()),
Err(LinalgError::Lapack(e)) if matches!(e, lapack::error::Error::LapackComputationalFailure {..}) =>
Err(LinalgError::Lapack(e)) if matches!(e, lax::error::Error::LapackComputationalFailure {..}) =>
{
// Determinant is zero.
Ok((A::Real::zero(), A::Real::neg_infinity()))
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/src/svddc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use super::{convert::*, error::*, layout::*, types::*};
use ndarray::*;

pub use lapack::svddc::UVTFlag;
pub use lax::UVTFlag;

/// Singular-value decomposition of matrix (copying) by divide-and-conquer
pub trait SVDDC {
Expand Down
4 changes: 2 additions & 2 deletions ndarray-linalg/src/triangular.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! Methods for triangular matrices

use lax::*;
use ndarray::*;
use num_traits::Zero;

use super::convert::*;
use super::error::*;
use super::lapack::*;
use super::layout::*;
use super::types::*;

pub use super::lapack::Diag;
pub use lax::Diag;

/// solve a triangular system with upper triangular matrix
pub trait SolveTriangular<A, S, D>
Expand Down
4 changes: 2 additions & 2 deletions ndarray-linalg/src/tridiagonal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use super::convert::*;
use super::error::*;
use super::lapack::*;
use super::layout::*;
use cauchy::Scalar;
use lax::*;
use ndarray::*;
use num_traits::One;

pub use lapack::tridiagonal::{LUFactorizedTridiagonal, Tridiagonal};
pub use lax::{LUFactorizedTridiagonal, Tridiagonal};

/// An interface for making a Tridiagonal struct.
pub trait ExtractTridiagonal<A: Scalar> {
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Basic types and their methods for linear algebra

pub use super::lapack::Lapack;
pub use cauchy::Scalar;
pub use lax::Lapack;

pub use num_complex::Complex32 as c32;
pub use num_complex::Complex64 as c64;