Re: [ojAlgo-user] Changing a few values to a BasicMatrix
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Anders P. <an...@op...> - 2015-10-23 15:15:05
|
To clarify when/if you’re working with immutable matrices you have to this: tmpTensor[9] = tmpTensor[9].add(56, 0, tmpDifference); > On 23 okt. 2015, at 17:03, Anders Peterson <an...@op...> wrote: > > You could do something like this: > > BasicMatrix[] tmpTensor = new BasicMatrix[10] {….}; > > BasicMatrix tmpDifference = PrimitiveMatrix.FACTORY.getBuilder(3, 1600).fillAll(3.14).build(); > > tmpTensor[9].add(56, 0, tmpDifference); > > That will change rows 56, 57 and 58 of matrix 9. > > It doesn’t cost you (CPU) anything now. Depending on what you do it may cost you later. > > > I’m guessing BasicMatrix is not a good choice for you. Doesn’t sound like immutable objects suit your needs. Try working with PrimitiveDenseStore instead. > > PrimitiveDenseStore[] tmpTensor = new PrimitiveDenseStore[10] {….}; > > > Did you read the "Getting Started: Linear Algebra” wiki page? > > https://github.com/optimatika/ojAlgo/wiki/Getting-Started > > > In the org.ojalgo.array package there are classes supporting 1, 2 or “any” dimensional arrays of double, BigDecimal, ComplexNumber, Quaternion and RationalNumber. The arrays can be sparse or dense and arbitrarily large. You can directly do this: > > ArrayAnyD<Double> tmpTensor3D = ArrayAnyD.PRIMITIVE.makeZero(1000, 1600, 10); > > > I must admit that the code supporting the any-dimensional features is underdeveloped and not very well tested. 99% seems to only need 1 or 2 dimensional arrays (vectors and matrices). If the ArrayAnyD class doesn’t have what you need it can be added. > > > /Anders > > > >> On 23 okt. 2015, at 15:53, Stathis Maroulis <sta...@gm...> wrote: >> >> Hello, >> I'm currently trying to implement a 3D Tensor library, using Ojalgo. Every time i want to change some elements of the matrices I am using a builder. But i think I'm losing a lot of (CPU) time doing this. >> For example when if have a 1000x1600x10 tensor (an array of ten 1000x16000 BasicMatrix matrices) and what to change some rows, i have to rebuilt the whole tensor. Am I missing something or this is the way we do this? >> Thanks for you time. >> >> >> Stathis Maroulis >> ------------------------------------------------------------------------------ >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |