pub fn dense_problem(y: Vec<f64>, x: Vec<Vec<f64>>) -> Result<SvmProb> {
    // Data check: Problem is not empty
    if y.len() == 0 || x.len() == 0 {
        return Err(SvmErr::InvalidDataError(format!("Cannot create problem from empty vector")))
    }

    // Check data
    let len = y.len();
    if x.len() != len {
        return Err(SvmErr::InvalidDataError(
            format!("y vector has length {} but x vector has length {}", len, x.len())))
    }

    // Convert the data into a vector of C arrays of SVMNode structs
    let mut x_data: Vec<*const sys::CSVMNode> = Vec::new();
    for row in x {
        let mut new_row = Vec::new();
        for (i, &cell) in row.iter().enumerate() {
            if i != 0 {
                new_row.push(sys::CSVMNode { index: i as i32, value: cell });
            }
        }
        new_row.push(sys::CSVMNode { index: -1, value: 0.0 });
        x_data.push(new_row.as_ptr());
    }

    // Build the SvmProb struct
    Ok(SvmProb {
        c_problem: sys::CSVMProb {
            l: len as i32,
            y: y.as_ptr(),
            data: x_data.as_ptr()
        }
    })
}
/// Create a SvmProb from a one-dimensional output vector and a two-dimensional input vector.
Create a SvmProb from a one-dimensional output vector and a two-dimensional input vector.
Create a SvmProb from a one - dimensional output vector and a two - dimensional input vector .
pub fn dense_problem(y: Vec<f64>, x: Vec<Vec<f64>>) -> Result<SvmProb> {
    // Data check: Problem is not empty
    if y.len() == 0 || x.len() == 0 {
        return Err(SvmErr::InvalidDataError(format!("Cannot create problem from empty vector")))
    }
    // Check data
    let len = y.len();
    if x.len() != len {
        return Err(SvmErr::InvalidDataError(
            format!("y vector has length {} but x vector has length {}", len, x.len())))
    }
    // Convert the data into a vector of C arrays of SVMNode structs
    let mut x_data: Vec<*const sys::CSVMNode> = Vec::new();
    for row in x {
        let mut new_row = Vec::new();
        for (i, &cell) in row.iter().enumerate() {
            if i != 0 {
                new_row.push(sys::CSVMNode { index: i as i32, value: cell });
            }
        }
        new_row.push(sys::CSVMNode { index: -1, value: 0.0 });
        x_data.push(new_row.as_ptr());
    }
    // Build the SvmProb struct
    Ok(SvmProb {
        c_problem: sys::CSVMProb {
            l: len as i32,
            y: y.as_ptr(),
            data: x_data.as_ptr()
        }
    })
}
pub fn dense_problem ( y : Vec < f64 > , x : Vec < Vec < f64 > > ) -> Result < SvmProb > { // Data check: Problem is not empty if y . len ( ) == 0 || x . len ( ) == 0 { return Err ( SvmErr :: InvalidDataError ( format ! ( " " ) ) ) } // Check data let len = y . len ( ) ; if x . len ( ) != len { return Err ( SvmErr :: InvalidDataError ( format ! ( " " len x len ( ) ) ) ) } // Convert the data into a vector of C arrays of SVMNode structs let mut x_data : Vec < * const sys :: CSVMNode > = Vec :: new ( ) ; for row in x { let mut new_row = Vec :: new ( ) ; for ( i , & cell ) in row . iter ( ) . enumerate ( ) { if i != 0 { new_row . push ( sys :: CSVMNode { index : i as i32 , value : cell } ) ; } } new_row . push ( sys :: CSVMNode { index : - 1 , value : 0.0 } ) ; x_data . push ( new_row . as_ptr ( ) ) ; } // Build the SvmProb struct Ok ( SvmProb { c_problem : sys :: CSVMProb { l : len as i32 , y : y . as_ptr ( ) , data : x_data . as_ptr ( ) } } ) }
Create a SvmProb from a one-dimensional output vector and a two-dimensional input vector.
Create a SvmProb from a one - dimensional output vector and a two - dimensional input vector .
y
Vec<f64>
x
Vec<Vec<f64>>
y
Vec<f64>
x
Vec<Vec<f64>>