Skip to content

Can't compile svm example #361

@wormtql

Description

@wormtql

I'm executing exactly the same code as the winequality_svm example, with my Cargo.toml as close as possible to the example Cargo.toml

[package]
name = "svm_example"
version = "0.1.0"
edition = "2021"

[dependencies]
linfa-svm = "0.7.0"
linfa = "0.7.0"
linfa-datasets = { version = "0.7.0", features = ["winequality", "diabetes"] }
ndarray = "0.15"
num-traits = "0.2"
linfa-kernel = "0.7.0"

My rust toolchain is nightly 1.83.0
And got the compiler error:

error[E0277]: cannot multiply `&CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>` by `&ndarray::ArrayBase<ViewRepr<&F>, Dim<[usize; 2]>>`
  --> C:\Users\admin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\linfa-kernel-0.7.0\src\inner.rs:64:18
   |
64 |         self.mul(rhs)
   |              --- ^^^ no implementation for `&CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>> * &ndarray::ArrayBase<ViewRepr<&F>, Dim<[usize; 2]>>`
   |              |
   |              required by a bound introduced by this call
   |
   = help: the trait `Mul<&ndarray::ArrayBase<ViewRepr<&F>, Dim<[usize; 2]>>>` is not implemented for `&CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>`
   = help: the following other types implement trait `Mul<Rhs>`:
             `&CsMatBase<N, I, IpS, IS, DS, Iptr>` implements `Mul<&ndarray::ArrayBase<DS2, ndarray::dimension::dim::Dim<[usize; 1]>>>`
             `&CsMatBase<N, I, IpS, IS, DS, Iptr>` implements `Mul<&ndarray::ArrayBase<DS2, ndarray::dimension::dim::Dim<[usize; 2]>>>`
             `&CsMatBase<N, I, IpS1, IS1, DS1, Iptr>` implements `Mul<&CsMatBase<N, I, IpS2, IS2, DS2, Iptr>>`
             `&CsMatBase<N, I, IpS1, IS1, DS1, Iptr>` implements `Mul<&CsVecBase<IS2, DS2, N, I>>`
             `&CsMatBase<f32, I, IpStorage, IStorage, DStorage, Iptr>` implements `Mul<f32>`
             `&CsMatBase<f64, I, IpStorage, IStorage, DStorage, Iptr>` implements `Mul<f64>`
             `&CsMatBase<i16, I, IpStorage, IStorage, DStorage, Iptr>` implements `Mul<i16>`
             `&CsMatBase<i32, I, IpStorage, IStorage, DStorage, Iptr>` implements `Mul<i32>`
           and 8 others

error[E0277]: cannot multiply `&CsMatBase<F, usize, &[usize], &[usize], &[F]>` by `&ndarray::ArrayBase<ViewRepr<&F>, Dim<[usize; 2]>>`
   --> C:\Users\admin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\linfa-kernel-0.7.0\src\inner.rs:109:18
    |
109 |         self.mul(rhs)
    |              --- ^^^ no implementation for `&CsMatBase<F, usize, &[usize], &[usize], &[F]> * &ndarray::ArrayBase<ViewRepr<&F>, Dim<[usize; 2]>>`
    |              |
    |              required by a bound introduced by this call
    |
    = help: the trait `Mul<&ndarray::ArrayBase<ViewRepr<&F>, Dim<[usize; 2]>>>` is not implemented for `&CsMatBase<F, usize, &[usize], &[usize], &[F]>`
    = help: the following other types implement trait `Mul<Rhs>`:
              `&CsMatBase<N, I, IpS, IS, DS, Iptr>` implements `Mul<&ndarray::ArrayBase<DS2, ndarray::dimension::dim::Dim<[usize; 1]>>>`
              `&CsMatBase<N, I, IpS, IS, DS, Iptr>` implements `Mul<&ndarray::ArrayBase<DS2, ndarray::dimension::dim::Dim<[usize; 2]>>>`
              `&CsMatBase<N, I, IpS1, IS1, DS1, Iptr>` implements `Mul<&CsMatBase<N, I, IpS2, IS2, DS2, Iptr>>`
              `&CsMatBase<N, I, IpS1, IS1, DS1, Iptr>` implements `Mul<&CsVecBase<IS2, DS2, N, I>>`
              `&CsMatBase<f32, I, IpStorage, IStorage, DStorage, Iptr>` implements `Mul<f32>`
              `&CsMatBase<f64, I, IpStorage, IStorage, DStorage, Iptr>` implements `Mul<f64>`
              `&CsMatBase<i16, I, IpStorage, IStorage, DStorage, Iptr>` implements `Mul<i16>`
              `&CsMatBase<i32, I, IpStorage, IStorage, DStorage, Iptr>` implements `Mul<i32>`
            and 8 others

For more information about this error, try `rustc --explain E0277`.
error: could not compile `linfa-kernel` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions