docstr: Construct a vectorized tensor from a PARAFAC2 decomposition. Uneven
  slices are padded by zeros.
  
  The decomposition is on the form :math:`(A [B_i] C)` such that
  the i-th frontal slice, :math:`X_i`, of :math:`X` is given by
  
  .. math::
  
      X_i = B_i diag(a_i) C^T,
  
  where :math:`diag(a_i)` is the diagonal matrix whose nonzero
  entries are  equal to the :math:`i`-th row of the :math:`I
  times R` factor matrix :math:`A`, :math:`B_i` is a :math:`J_i
  times R` factor matrix such that the cross product matrix :math:
  `B_{i_1}^T B_{i_1}`is constant for all :math:`i`, and :math:`C`
  is a :math:`K times R` factor matrix. To compute this
  decomposition, we reformulate the expression for :math:`B_i`
  such that
  
  .. math::
  
      B_i = P_i B,
  
  where :math:`P_i` is a :math:`J_i times R` orthogonal matrix and :math:`B` is a
  :math:`R times R` matrix.
  
  An alternative formulation of the PARAFAC2 decomposition is that
  the tensor element :math:`X_{ijk}` is given by
  
  .. math::
  
      X_{ijk} = sum_{r=1}^R A_{ir} B_{ijr} C_{kr},
  
  with the same constraints hold for :math:`B_i` as above.
  
  Parameters
  ----------
  parafac2_tensor : Parafac2Tensor - (weight, factors, projection_matrices)
      * weights
      1D array of shape (rank, ) weights of the factors
      * factors
      List of factors of the PARAFAC2 decomposition Contains the matrices
      :math:`A, :math:`B` and :math:`C` described above
      * projection_matrices
          List of projection matrices used to create evolving factors.
  
  Returns
  -------
      Full constructed tensor. Uneven slices are padded with zeros.6
docstr_tok: ["Construct","a","vectorized","tensor","from","a","PARAFAC2","decomposition",".","Uneven","slices","are","padded","by","zeros",".","The","decomposition","is","on","the","form",":","math",":","`","(","A","[","B_i","]","C",")","`","such","that","the","i-th","frontal","slice",",",":","math",":","`","X_i","`",",","of",":","math",":","`","X","`","is","given","by","..","math",":",":","X_i","=","B_i","diag","(","a_i",")","C^T",",","where",":","math",":","`","diag","(","a_i",")","`","is","the","diagonal","matrix","whose","nonzero","entries","are","equal","to","the",":","math",":","`","i","`","-th","row","of","the",":","math",":","`","I","times","R","`","factor","matrix",":","math",":","`","A","`",",",":","math",":","`","B_i","`","is","a",":","math",":","`","J_i","times","R","`","factor","matrix","such","that","the","cross","product","matrix",":","math",":","`","B_","{","i_1","}","^T","B_","{","i_1","}","`","is","constant","for","all",":","math",":","`","i","`",",","and",":","math",":","`","C","`","is","a",":","math",":","`","K","times","R","`","factor","matrix",".","To","compute","this","decomposition",",","we","reformulate","the","expression","for",":","math",":","`","B_i","`","such","that","..","math",":",":","B_i","=","P_i","B",",","where",":","math",":","`","P_i","`","is","a",":","math",":","`","J_i","times","R","`","orthogonal","matrix","and",":","math",":","`","B","`","is","a",":","math",":","`","R","times","R","`","matrix",".","An","alternative","formulation","of","the","PARAFAC2","decomposition","is","that","the","tensor","element",":","math",":","`","X_","{","ijk","}","`","is","given","by","..","math",":",":","X_","{","ijk","}","=","sum_","{","r=1","}","^R","A_","{","ir","}","B_","{","ijr","}","C_","{","kr","}",",","with","the","same","constraints","hold","for",":","math",":","`","B_i","`","as","above",".","Parameters","--","--","--","--","--","parafac2_tensor",":","Parafac2Tensor","-","(","weight",",","factors",",","projection_matrices",")","*","weights","1D","array","of","shape","(","rank",",",")","weights","of","the","factors","*","factors","List","of","factors","of","the","PARAFAC2","decomposition","Contains","the","matrices",":","math",":","`","A",",",":","math",":","`","B","`","and",":","math",":","`","C","`","described","above","*","projection_matrices","List","of","projection","matrices","used","to","create","evolving","factors",".","Returns","--","--","--","-","Full","constructed","tensor",".","Uneven","slices","are","padded","with","zeros.6"]
code: def parafac2_to_vec(parafac2_tensor):
      """Construct a vectorized tensor from a PARAFAC2 decomposition. Uneven
      slices are padded by zeros.
  
      The decomposition is on the form :math:`(A [B_i] C)` such that
      the i-th frontal slice, :math:`X_i`, of :math:`X` is given by
  
      .. math::
  
          X_i = B_i diag(a_i) C^T,
  
      where :math:`diag(a_i)` is the diagonal matrix whose nonzero
      entries are  equal to the :math:`i`-th row of the :math:`I
      times R` factor matrix :math:`A`, :math:`B_i` is a :math:`J_i
      times R` factor matrix such that the cross product matrix :math:
      `B_{i_1}^T B_{i_1}`is constant for all :math:`i`, and :math:`C`
      is a :math:`K times R` factor matrix. To compute this
      decomposition, we reformulate the expression for :math:`B_i`
      such that
  
      .. math::
  
          B_i = P_i B,
  
      where :math:`P_i` is a :math:`J_i times R` orthogonal matrix and :math:`B` is a
      :math:`R times R` matrix.
  
      An alternative formulation of the PARAFAC2 decomposition is that
      the tensor element :math:`X_{ijk}` is given by
  
      .. math::
  
          X_{ijk} = sum_{r=1}^R A_{ir} B_{ijr} C_{kr},
  
      with the same constraints hold for :math:`B_i` as above.
  
      Parameters
      ----------
      parafac2_tensor : Parafac2Tensor - (weight, factors, projection_matrices)
          * weights
          1D array of shape (rank, ) weights of the factors
          * factors
          List of factors of the PARAFAC2 decomposition Contains the matrices
          :math:`A, :math:`B` and :math:`C` described above
          * projection_matrices
              List of projection matrices used to create evolving factors.
  
      Returns
      -------
          Full constructed tensor. Uneven slices are padded with zeros.6
      """
      return ivy.reshape(
          ivy.Parafac2Tensor.parafac2_to_tensor(parafac2_tensor), (-1)
      )
  
imports: from .base import FactorizedTensor
  import ivy
  from copy import deepcopy
label_desc: Use image node_id 19 for calling the Parafac2Tensor obj's underlying member method code with example usage: obj.parafac2_to_vec(parafac2_tensor) and returns: ivy