Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78977142
ArrayUtil.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Aug 24, 02:21
Size
1 KB
Mime Type
text/x-c
Expires
Mon, Aug 26, 02:21 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
20130570
Attached To
R9360 PCSC_git
ArrayUtil.hpp
View Options
/*
* ArrayUtil.cpp
*
* Utility functions for using 1D and 2D arrays
*
* Created on: Oct 8, 2012
* Author: Radu Popescu <radu.popescu@epfl.ch>
*/
#ifndef ARRAY_UTIL_H
#define ARRAY_UTIL_H
#include <cassert>
#include <fstream>
#include <iostream>
/*
* Reads a matrix from a file/. This function handles memory allocation but
* the DeleteMatrix function must be called at the end of the program
*/
void
Read
(
const
char
*
file_name
,
double
**&
M
,
int
&
n_rows
,
int
&
n_cols
);
/*
* Reads a vector from a file/. This function handles memory allocation but
* the DeleteMatrix function must be called at the end of the program
*/
void
Read
(
const
char
*
file_name
,
double
*&
v
,
int
&
n_elem
);
// Allocate memory for an n_rows x n_cols matrix
void
Allocate
(
double
**&
M
,
const
int
n_rows
,
const
int
n_cols
);
// Allocate memory for an n_elem matrix
void
Allocate
(
double
*&
v
,
const
int
n_elem
);
// Release memory used by a previously allocated matrix
void
Delete
(
double
**&
M
,
const
int
n_rows
);
// Release memory used by a previously allocated vector
void
Delete
(
double
*&
v
);
// Does matrix multiplication C = A * B ; C must be allocated
void
Multiply
(
double
**
A
,
double
**
B
,
const
double
n_rows_A
,
const
double
n_cols_A
,
const
double
n_rows_B
,
const
double
n_cols_B
,
double
**&
C
);
// Does matrix multiplication w = v * A; w must be allocated
void
Multiply
(
double
*
v
,
double
**
A
,
const
double
n_rows_A
,
const
double
n_cols_A
,
double
*&
w
);
// Does matrix multiplication w = A * v; w must be allocated
void
Multiply
(
double
**
A
,
double
*
v
,
const
double
n_rows_A
,
const
double
n_cols_A
,
double
*&
w
);
// Does matrix multiplication B = A * s ; B must be allocated
void
Multiply
(
double
**
A
,
const
double
s
,
const
double
n_rows_A
,
const
double
n_cols_A
,
double
**&
B
);
void
Print
(
double
**
M
,
const
int
n_rows
,
const
int
n_cols
,
std
::
ostream
&
os
);
void
Print
(
double
*
v
,
const
int
n_elem
,
std
::
ostream
&
os
,
const
bool
transpose
);
#endif
// ARRAY_UTIL_H
Event Timeline
Log In to Comment