Re: [deal.II] Tensor<1, dim> initialization
On 1/5/20 6:15 AM, A.Z Ihsan wrote: > just a small question. > > suppose we want to construct a rank-1 tensor in 3 dim with values (1, 1, 0) : > Tensor<1, 3> b(); In addition the other answer, you can also initialize the tensor like this: Tensor<1,3> t2({1., 1., 0.}); or Tensor<1,3> t4{{1., 1., 0.}}; Best W. -- Wolfgang Bangerth email: bange...@colostate.edu www: http://www.math.colostate.edu/~bangerth/ -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/a5b0028f-6cb1-dd90-38db-48d9cbd06318%40colostate.edu.
Re: [deal.II] Tensor<1, dim> initialization
Thank you Matthias. It works perfectly! BR, Ihsan On Sunday, January 5, 2020 at 3:41:38 PM UTC+1, Matthias Maier wrote: > > > On Sun, Jan 5, 2020, at 07:15 CST, "A.Z Ihsan" > wrote: > > > Tensor<1, 3> b(); > > If you write this then you declare a function "b" returning a > Tensor<1,3>. Declare the tensor without the parentheses: > > Tensor<1, 3> b; > > You can access individual elements of the tensor via operator[]: > > b[0] = 1; > b[1] = 1; > b[2] = 0; > > And you can do meaningful mathematical tensor operations. Including, > scaling a tensor > > auto a = 5. * b; > > Adding two tensors together: > > auto c = a + b; > > Taking the inner product: > > auto k = a * b; > > etc. > > Best, > Matthias > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/9141b21d-f581-4493-a4d9-644b29255f39%40googlegroups.com.
Re: [deal.II] Tensor<1, dim> initialization
On Sun, Jan 5, 2020, at 07:15 CST, "A.Z Ihsan" wrote: > Tensor<1, 3> b(); If you write this then you declare a function "b" returning a Tensor<1,3>. Declare the tensor without the parentheses: Tensor<1, 3> b; You can access individual elements of the tensor via operator[]: b[0] = 1; b[1] = 1; b[2] = 0; And you can do meaningful mathematical tensor operations. Including, scaling a tensor auto a = 5. * b; Adding two tensors together: auto c = a + b; Taking the inner product: auto k = a * b; etc. Best, Matthias -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/87eewe2cf4.fsf%4043-1.org.
[deal.II] Tensor<1, dim> initialization
Hi there, just a small question. suppose we want to construct a rank-1 tensor in 3 dim with values (1, 1, 0) : Tensor<1, 3> b(); i read a documentation we can use array_type as a parameter construction, but still i aml confused how to use it. any idea how to use it? BR, Ihsan -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/db9eecc4-9de6-4a12-b7dd-a3d262f1314c%40googlegroups.com.