Code Monkey home page Code Monkey logo

Comments (2)

AnthonyKalaitzis avatar AnthonyKalaitzis commented on May 29, 2024

I wouldn't mind giving this one a try. Would it be preferred that they generate identity matrices or 0 matrices as defaults?

from nalgebra.

acxz avatar acxz commented on May 29, 2024

I just picked up this library and came across this issue as well.
Just running the following line:

let x = nalgebra::SVector::<f64, 37>::default();

fails with the following:

error[E0599]: the function or associated item `default` exists for struct `Matrix<f64, Const<37>, Const<1>, ArrayStorage<f64, 37, 1>>`, but its trait bounds were not satisfied
   --> src\bin\main.rs:136:51
    |
136 |     let x = nalgebra::SVector::<f64, 37>::default();
    |                                                   ^^^^^^^ function or associated item cannot be called due to unsatisfied trait bounds
    |
   ::: C:\Users\acxz\.cargo\registry\src\index.crates.io-6f17d22bba15001f\nalgebra-0.32.3\src\base\array_storage.rs:46:1
    |
46  | pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
    | ---------------------------------------------------------- doesn't satisfy `ArrayStorage<f64, 37, 1>: Default`
    |
   ::: C:\Users\acxz\.cargo\registry\src\index.crates.io-6f17d22bba15001f\nalgebra-0.32.3\src\base\matrix.rs:175:1
    |
175 | pub struct Matrix<T, R, C, S> {
    | ----------------------------- doesn't satisfy `_: Default`
    |
    = note: the following trait bounds were not satisfied:
            `ArrayStorage<f64, 37, 1>: Default`
            which is required by `Matrix<f64, Const<37>, Const<1>, ArrayStorage<f64, 37, 1>>: Default`   

Values up to 32 do work however, looks like for static vectors, default isn't implemented for sizes up to 64.

Would implementing this be feasible and part of the roadplan?

Edit: going through the code I see that values up to 127 are included:

from_to_typenum!(
U0, 0; /*U1,1;*/ U2, 2; U3, 3; U4, 4; U5, 5; U6, 6; U7, 7; U8, 8; U9, 9; U10, 10; U11, 11; U12, 12; U13, 13; U14, 14; U15, 15; U16, 16; U17, 17; U18, 18;
U19, 19; U20, 20; U21, 21; U22, 22; U23, 23; U24, 24; U25, 25; U26, 26; U27, 27; U28, 28; U29, 29; U30, 30; U31, 31; U32, 32; U33, 33; U34, 34; U35, 35; U36, 36; U37, 37;
U38, 38; U39, 39; U40, 40; U41, 41; U42, 42; U43, 43; U44, 44; U45, 45; U46, 46; U47, 47; U48, 48; U49, 49; U50, 50; U51, 51; U52, 52; U53, 53; U54, 54; U55, 55; U56, 56;
U57, 57; U58, 58; U59, 59; U60, 60; U61, 61; U62, 62; U63, 63; U64, 64; U65, 65; U66, 66; U67, 67; U68, 68; U69, 69; U70, 70; U71, 71; U72, 72; U73, 73; U74, 74; U75, 75;
U76, 76; U77, 77; U78, 78; U79, 79; U80, 80; U81, 81; U82, 82; U83, 83; U84, 84; U85, 85; U86, 86; U87, 87; U88, 88; U89, 89; U90, 90; U91, 91; U92, 92; U93, 93; U94, 94;
U95, 95; U96, 96; U97, 97; U98, 98; U99, 99; U100, 100; U101, 101; U102, 102; U103, 103; U104, 104; U105, 105; U106, 106; U107, 107; U108, 108; U109, 109; U110, 110;
U111, 111; U112, 112; U113, 113; U114, 114; U115, 115; U116, 116; U117, 117; U118, 118; U119, 119; U120, 120; U121, 121; U122, 122; U123, 123; U124, 124; U125, 125; U126, 126;
U127, 127
);

Is there a reason or has it been simply overlooked that sizes above 32 do not implement the default trait?

from nalgebra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.