本文整理汇总了C++中eigen::Matrix::sqrt方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::sqrt方法的具体用法?C++ Matrix::sqrt怎么用?C++ Matrix::sqrt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Matrix
的用法示例。
在下文中一共展示了Matrix::sqrt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void run ()
{
auto input_header = Header::open (argument[0]);
Header output_header (input_header);
output_header.datatype() = DataType::from_command_line (DataType::from<float> ());
// Linear
transform_type linear_transform;
bool linear = false;
auto opt = get_options ("linear");
if (opt.size()) {
linear = true;
linear_transform = load_transform (opt[0][0]);
} else {
linear_transform.setIdentity();
}
// Replace
const bool replace = get_options ("replace").size();
if (replace && !linear) {
INFO ("no linear is supplied so replace with the default (identity) transform");
linear = true;
}
// Template
opt = get_options ("template");
Header template_header;
if (opt.size()) {
if (replace)
throw Exception ("you cannot use the -replace option with the -template option");
template_header = Header::open (opt[0][0]);
for (size_t i = 0; i < 3; ++i) {
output_header.size(i) = template_header.size(i);
output_header.spacing(i) = template_header.spacing(i);
}
output_header.transform() = template_header.transform();
add_line (output_header.keyval()["comments"], std::string ("regridded to template image \"" + template_header.name() + "\""));
}
// Warp 5D warp
// TODO add reference to warp format documentation
opt = get_options ("warp_full");
Image<default_type> warp;
if (opt.size()) {
warp = Image<default_type>::open (opt[0][0]).with_direct_io();
if (warp.ndim() != 5)
throw Exception ("the input -warp_full image must be a 5D file.");
if (warp.size(3) != 3)
throw Exception ("the input -warp_full image must have 3 volumes (x,y,z) in the 4th dimension.");
if (warp.size(4) != 4)
throw Exception ("the input -warp_full image must have 4 volumes in the 5th dimension.");
if (linear)
throw Exception ("the -warp_full option cannot be applied in combination with -linear since the "
"linear transform is already included in the warp header");
}
// Warp from image1 or image2
int from = 1;
opt = get_options ("from");
if (opt.size()) {
from = opt[0][0];
if (!warp.valid())
WARN ("-from option ignored since no 5D warp was input");
}
// Warp deformation field
opt = get_options ("warp");
if (opt.size()) {
if (warp.valid())
throw Exception ("only one warp field can be input with either -warp or -warp_mid");
warp = Image<default_type>::open (opt[0][0]).with_direct_io (Stride::contiguous_along_axis(3));
if (warp.ndim() != 4)
throw Exception ("the input -warp file must be a 4D deformation field");
if (warp.size(3) != 3)
throw Exception ("the input -warp file must have 3 volumes in the 4th dimension (x,y,z positions)");
}
// Inverse
const bool inverse = get_options ("inverse").size();
if (inverse) {
if (!(linear || warp.valid()))
throw Exception ("no linear or warp transformation provided for option '-inverse'");
if (warp.valid())
if (warp.ndim() == 4)
throw Exception ("cannot apply -inverse with the input -warp_df deformation field.");
linear_transform = linear_transform.inverse();
}
// Half
const bool half = get_options ("half").size();
if (half) {
if (!(linear))
throw Exception ("no linear transformation provided for option '-half'");
{
Eigen::Matrix<default_type, 4, 4> temp;
temp.row(3) << 0, 0, 0, 1.0;
temp.topLeftCorner(3,4) = linear_transform.matrix().topLeftCorner(3,4);
linear_transform.matrix() = temp.sqrt().topLeftCorner(3,4);
}
}
//.........这里部分代码省略.........