mirror of
https://github.com/eternal-flame-AD/unitdc-rs.git
synced 2024-11-27 21:06:43 -06:00
Add SPDX header to rs files
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
parent
c951072c35
commit
69df7400c7
11 changed files with 159 additions and 8 deletions
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
io::{BufReader, Read},
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use num_rational::BigRational;
|
||||
use num_traits::{FromPrimitive, ToPrimitive};
|
||||
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::quantity::units::{BaseUnit, DerivedUnit};
|
||||
|
||||
use super::{Interpreter, InterpreterError, InterpreterResult};
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use super::{Interpreter, InterpreterError, InterpreterResult};
|
||||
|
||||
impl<'a> Interpreter<'a> {
|
||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/// Interpreter for UnitDC expressions.
|
||||
pub mod interpreter;
|
||||
/// A module for evaluating linear systems of equations.
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
use log::debug;
|
||||
use num_traits::Signed;
|
||||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use num_traits::{One, Zero};
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
ops::{Add, Div, Mul, Neg, Sub},
|
||||
|
@ -26,7 +39,8 @@ where
|
|||
+ Div<Output = T>
|
||||
+ Neg<Output = T>
|
||||
+ Clone
|
||||
+ Signed,
|
||||
+ Zero
|
||||
+ One,
|
||||
{
|
||||
matrix: Vec<Vec<T>>,
|
||||
}
|
||||
|
@ -40,8 +54,8 @@ where
|
|||
+ Neg<Output = T>
|
||||
+ PartialOrd
|
||||
+ Clone
|
||||
+ Signed
|
||||
+ Debug,
|
||||
+ Zero
|
||||
+ One,
|
||||
{
|
||||
pub fn n(&self) -> usize {
|
||||
self.matrix.len()
|
||||
|
@ -126,15 +140,12 @@ where
|
|||
self.n_pivoted() < self.m() - 1
|
||||
}
|
||||
pub fn solve(&mut self) -> Option<Vec<T>> {
|
||||
debug!("starting matrix: {:?}", self.matrix);
|
||||
for col in 0..if self.n() < self.m() {
|
||||
self.n()
|
||||
} else {
|
||||
self.m()
|
||||
} {
|
||||
debug!("col: {}", col);
|
||||
self.reduce_column(col);
|
||||
debug!("matrix: {:?}", self.matrix);
|
||||
}
|
||||
let mut result = Vec::new();
|
||||
for row in 0..self.n() {
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::{
|
||||
fmt::Display,
|
||||
ops::{Add, Div, Mul, Sub},
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::{Debug, Display},
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::{
|
||||
fmt::Display,
|
||||
io::{BufReader, Read},
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use super::TokenizerError;
|
||||
use num_bigint::{BigInt, BigUint};
|
||||
use num_rational::BigRational;
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2024 eternal-flame-AD <yume@yumechi.jp>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use num_rational::BigRational;
|
||||
use num_traits::ToPrimitive;
|
||||
|
||||
|
|
Loading…
Reference in a new issue