1 /*
2 
3     Copyright (C) 2014, The University of Texas at Austin
4 
5     This file is part of libflame and is available under the 3-Clause
6     BSD license, which can be found in the LICENSE file at the top-level
7     directory, or at http://opensource.org/licenses/BSD-3-Clause
8 
9 */
10 
11 #include "blis1.h"
12 
bl1_sfree_saved_contigm(int m,int n,float * a_save,int a_rs_save,int a_cs_save,float ** a,int * a_rs,int * a_cs)13 void bl1_sfree_saved_contigm( int m, int n, float* a_save, int a_rs_save, int a_cs_save, float** a, int* a_rs, int* a_cs )
14 {
15 	if ( bl1_is_gen_storage( a_rs_save, a_cs_save ) )
16 	{
17 		// Copy the contents of the temporary matrix back to the original.
18 		bl1_scopymt( BLIS1_NO_TRANSPOSE,
19 		             m,
20 		             n,
21 		             *a,     *a_rs,     *a_cs,
22 		             a_save, a_rs_save, a_cs_save );
23 
24 		// Free the temporary contiguous storage for the matrix.
25 		bl1_sfree( *a );
26 
27 		// Restore the original matrix address.
28 		*a = a_save;
29 
30 		// Restore the original row and column strides.
31 		*a_rs = a_rs_save;
32 		*a_cs = a_cs_save;
33 	}
34 }
35 
bl1_dfree_saved_contigm(int m,int n,double * a_save,int a_rs_save,int a_cs_save,double ** a,int * a_rs,int * a_cs)36 void bl1_dfree_saved_contigm( int m, int n, double* a_save, int a_rs_save, int a_cs_save, double** a, int* a_rs, int* a_cs )
37 {
38 	if ( bl1_is_gen_storage( a_rs_save, a_cs_save ) )
39 	{
40 		// Copy the contents of the temporary matrix back to the original.
41 		bl1_dcopymt( BLIS1_NO_TRANSPOSE,
42 		             m,
43 		             n,
44 		             *a,     *a_rs,     *a_cs,
45 		             a_save, a_rs_save, a_cs_save );
46 
47 		// Free the temporary contiguous storage for the matrix.
48 		bl1_dfree( *a );
49 
50 		// Restore the original matrix address.
51 		*a = a_save;
52 
53 		// Restore the original row and column strides.
54 		*a_rs = a_rs_save;
55 		*a_cs = a_cs_save;
56 	}
57 }
58 
bl1_cfree_saved_contigm(int m,int n,scomplex * a_save,int a_rs_save,int a_cs_save,scomplex ** a,int * a_rs,int * a_cs)59 void bl1_cfree_saved_contigm( int m, int n, scomplex* a_save, int a_rs_save, int a_cs_save, scomplex** a, int* a_rs, int* a_cs )
60 {
61 	if ( bl1_is_gen_storage( a_rs_save, a_cs_save ) )
62 	{
63 		// Copy the contents of the temporary matrix back to the original.
64 		bl1_ccopymt( BLIS1_NO_TRANSPOSE,
65 		             m,
66 		             n,
67 		             *a,     *a_rs,     *a_cs,
68 		             a_save, a_rs_save, a_cs_save );
69 
70 		// Free the temporary contiguous storage for the matrix.
71 		bl1_cfree( *a );
72 
73 		// Restore the original matrix address.
74 		*a = a_save;
75 
76 		// Restore the original row and column strides.
77 		*a_rs = a_rs_save;
78 		*a_cs = a_cs_save;
79 	}
80 }
81 
bl1_zfree_saved_contigm(int m,int n,dcomplex * a_save,int a_rs_save,int a_cs_save,dcomplex ** a,int * a_rs,int * a_cs)82 void bl1_zfree_saved_contigm( int m, int n, dcomplex* a_save, int a_rs_save, int a_cs_save, dcomplex** a, int* a_rs, int* a_cs )
83 {
84 	if ( bl1_is_gen_storage( a_rs_save, a_cs_save ) )
85 	{
86 		// Copy the contents of the temporary matrix back to the original.
87 		bl1_zcopymt( BLIS1_NO_TRANSPOSE,
88 		             m,
89 		             n,
90 		             *a,     *a_rs,     *a_cs,
91 		             a_save, a_rs_save, a_cs_save );
92 
93 		// Free the temporary contiguous storage for the matrix.
94 		bl1_zfree( *a );
95 
96 		// Restore the original matrix address.
97 		*a = a_save;
98 
99 		// Restore the original row and column strides.
100 		*a_rs = a_rs_save;
101 		*a_cs = a_cs_save;
102 	}
103 }
104 
105