Added doc comments [skip ci]

This commit is contained in:
Andrew Kane
2024-06-30 21:52:12 -07:00
parent da54ecc504
commit 762ec863e2
5 changed files with 8 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ pub struct MfModel {
pub q: *const c_float, pub q: *const c_float,
} }
/// Loss functions.
#[repr(C)] #[repr(C)]
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum Loss { pub enum Loss {

View File

@@ -2,6 +2,7 @@ use std::error;
use std::ffi::NulError; use std::ffi::NulError;
use std::fmt; use std::fmt;
/// An error.
#[derive(Debug, Eq, PartialEq)] #[derive(Debug, Eq, PartialEq)]
pub enum Error { pub enum Error {
Io, Io,

View File

@@ -1,20 +1,24 @@
use crate::bindings::{MfNode, MfProblem}; use crate::bindings::{MfNode, MfProblem};
/// A matrix.
pub struct Matrix { pub struct Matrix {
data: Vec<MfNode>, data: Vec<MfNode>,
} }
impl Matrix { impl Matrix {
/// Creates a new matrix.
pub fn new() -> Self { pub fn new() -> Self {
Self { data: Vec::new() } Self { data: Vec::new() }
} }
/// Creates a new matrix with a minimum capacity.
pub fn with_capacity(capacity: usize) -> Self { pub fn with_capacity(capacity: usize) -> Self {
Self { Self {
data: Vec::with_capacity(capacity), data: Vec::with_capacity(capacity),
} }
} }
/// Adds a value to the matrix.
pub fn push(&mut self, row_index: i32, column_index: i32, value: f32) { pub fn push(&mut self, row_index: i32, column_index: i32, value: f32) {
assert!(row_index >= 0); assert!(row_index >= 0);
assert!(column_index >= 0); assert!(column_index >= 0);

View File

@@ -4,6 +4,7 @@ use std::ffi::CString;
use std::path::Path; use std::path::Path;
use std::slice::Chunks; use std::slice::Chunks;
/// A model.
#[derive(Debug)] #[derive(Debug)]
pub struct Model { pub struct Model {
pub(crate) model: *mut MfModel, pub(crate) model: *mut MfModel,

View File

@@ -1,6 +1,7 @@
use crate::bindings::*; use crate::bindings::*;
use crate::{Error, Loss, Matrix, Model}; use crate::{Error, Loss, Matrix, Model};
/// A set of parameters.
pub struct Params { pub struct Params {
param: MfParameter, param: MfParameter,
} }