Skip to main content

DenseMatrix

Struct DenseMatrix 

Source
pub struct DenseMatrix { /* private fields */ }
Expand description

밀집 연접 비용 행렬 (Dense Matrix)

모든 연접 비용을 메모리에 저장하는 구현입니다. 희소 행렬이 아닌 경우에 적합합니다.

Implementations§

Source§

impl DenseMatrix

Source

pub fn new(lsize: usize, rsize: usize, default_cost: i16) -> DenseMatrix

새로운 밀집 행렬 생성 (모든 값을 기본값으로 초기화)

§Arguments
  • lsize - 좌문맥 크기
  • rsize - 우문맥 크기
  • default_cost - 기본 비용 값
Source

pub fn from_vec( lsize: usize, rsize: usize, costs: Vec<i16>, ) -> Result<DenseMatrix, DictError>

기존 비용 벡터로 밀집 행렬 생성

§Arguments
  • lsize - 좌문맥 크기
  • rsize - 우문맥 크기
  • costs - 비용 배열
§Returns

성공 시 DenseMatrix, 크기 불일치 시 에러

§Errors

비용 배열의 길이가 lsize * rsize와 일치하지 않으면 에러를 반환합니다.

Source

pub fn set(&mut self, right_id: u16, left_id: u16, cost: i16)

비용 설정

§Arguments
  • right_id - 우문맥 ID
  • left_id - 좌문맥 ID
  • cost - 비용 값
Source

pub fn from_def_file<P>(path: P) -> Result<DenseMatrix, DictError>
where P: AsRef<Path>,

텍스트 파일(matrix.def)에서 로드

§Format
<lsize> <rsize>
<right_id> <left_id> <cost>
...
§Arguments
  • path - matrix.def 파일 경로
§Errors

파일을 읽을 수 없거나 형식이 잘못된 경우 에러를 반환합니다.

Source

pub fn from_def_reader<R>(reader: R) -> Result<DenseMatrix, DictError>
where R: BufRead,

텍스트 리더에서 로드

§Errors

리더에서 데이터를 읽을 수 없거나 형식이 잘못된 경우 에러를 반환합니다.

Source

pub fn from_bin_file<P>(path: P) -> Result<DenseMatrix, DictError>
where P: AsRef<Path>,

바이너리 파일(matrix.bin)에서 로드

§Format
[2 bytes] lsize (little-endian u16)
[2 bytes] rsize (little-endian u16)
[lsize * rsize * 2 bytes] costs (little-endian i16 array)
§Errors

파일을 읽을 수 없거나 형식이 잘못된 경우 에러를 반환합니다.

Source

pub fn from_bin_bytes(data: &[u8]) -> Result<DenseMatrix, DictError>

바이너리 바이트에서 로드

§Errors

데이터가 유효한 바이너리 형식이 아닌 경우 에러를 반환합니다.

Source

pub fn from_compressed_file<P>(path: P) -> Result<DenseMatrix, DictError>
where P: AsRef<Path>,

압축된 바이너리 파일(matrix.bin.zst)에서 로드

§Errors

파일을 읽거나 압축 해제할 수 없는 경우 에러를 반환합니다.

Source

pub fn to_bin_bytes(&self) -> Vec<u8>

바이너리 형식으로 저장

Source

pub fn to_bin_file<P>(&self, path: P) -> Result<(), DictError>
where P: AsRef<Path>,

바이너리 파일로 저장

§Errors

파일을 쓸 수 없는 경우 에러를 반환합니다.

Source

pub fn to_compressed_file<P>( &self, path: P, level: i32, ) -> Result<(), DictError>
where P: AsRef<Path>,

압축된 바이너리 파일로 저장

§Errors

파일을 쓰거나 압축할 수 없는 경우 에러를 반환합니다.

Source

pub fn costs(&self) -> &[i16]

원본 비용 배열 참조

Source

pub fn memory_size(&self) -> usize

메모리 사용량 (바이트)

Trait Implementations§

Source§

impl Clone for DenseMatrix

Source§

fn clone(&self) -> DenseMatrix

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DenseMatrix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Matrix for DenseMatrix

Source§

fn get(&self, right_id: u16, left_id: u16) -> i32

연접 비용 조회 Read more
Source§

fn left_size(&self) -> usize

좌문맥 크기
Source§

fn right_size(&self) -> usize

우문맥 크기
Source§

fn entry_count(&self) -> usize

전체 엔트리 수

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ConnectionCost for T
where T: Matrix,

Source§

fn cost(&self, right_id: u16, left_id: u16) -> i32

두 문맥 ID 간의 연접 비용 반환 Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.