Reshape

데이터를 변경하지 않고 행렬의 모양을 변경합니다.

void  Reshape(
  const ulong  rows,     // 새로운 수 혹은 행
  const ulong  cols      // 새로운 수 혹은 열
   );

매개 변수

rows

[in]  새로운 수 혹은 행.

cols

[in]  새로운 수 혹은 열.

참조

매트릭스가 처리됩니다. 복사본이 생성되지 않습니다. 모든 크기를 지정할 수 있습니다(즉, rows_new*cols_new!=rows_old*cols_old). 매트릭스 버퍼가 증가하면 추가 값이 정의되지 않습니다.

   matrix matrix_a={{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
 
   Print("matrix_a\n",matrix_a);
   matrix_a.Reshape(2,6);
   Print("Reshape(2,6)\n",matrix_a);
   matrix_a.Reshape(3,5);
   Print("Reshape(3,5)\n",matrix_a);
   matrix_a.Reshape(2,4);
   Print("Reshape(2,4)\n",matrix_a);
 
  /*
  matrix_a
  [[1,2,3]
   [4,5,6]
   [7,8,9]
   [10,11,12]]
  Reshape(2,6)
  [[1,2,3,4,5,6]
   [7,8,9,10,11,12]]
  Reshape(3,5)
  [[1,2,3,4,5]
   [6,7,8,9,10]
   [11,12,0,3,0]]
  Reshape(2,4)
  [[1,2,3,4]
   [5,6,7,8]]
  */