ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
SquareWave.hh
1
6//
7// Copyright (C) 2011-2022 Yuki YOKOKURA
8// This program is free software;
9// you can redistribute it and/or modify it under the terms of the FreeBSD License.
10// For details, see the License.txt file.
11
12#ifndef SQUAREWAVE
13#define SQUAREWAVE
14
15#include "Matrix.hh"
16
17namespace ARCS { // ARCS名前空間
18double SquareWave(const double freq, const double phase, const double time);
19double SquareWave(const double freq, const double phase, const double time, const double starttime);
20
27template <size_t M>
28void SquareWave(const double freq, const double phase, const double time, Matrix<1,M>& output){
29 double r = sin(2.0*M_PI*freq*time + phase);
30 if(0 < r){
31 output = Matrix<1,M>::ones();
32 }else{
33 output = -Matrix<1,M>::ones();
34 }
35}
36
43template <size_t M>
44Matrix<1,M> SquareWaveVec(const double freq, const double phase, const double time){
45 Matrix<1,M> ret;
46 SquareWave(freq, phase, time, ret);
47 return ret;
48}
49
50}
51
52#endif
行列/ベクトル計算クラス(テンプレート版)
constexpr void sin(const ArcsMat< M, N, T > &U, ArcsMat< P, Q, R > &Y)
行列要素の正弦関数を計算する関数(引数渡し版)
Definition ArcsMatrix.hh:4210
static constexpr Matrix ones(void)
m行n列の要素がすべて1の行列を返す関数
Definition Matrix.hh:655