diff --git a/doc/samples/banded_adaptor.cpp b/doc/samples/banded_adaptor.cpp index b444c836..61552021 100644 --- a/doc/samples/banded_adaptor.cpp +++ b/doc/samples/banded_adaptor.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/banded_matrix.cpp b/doc/samples/banded_matrix.cpp index 23b0e0dc..68ee4d39 100644 --- a/doc/samples/banded_matrix.cpp +++ b/doc/samples/banded_matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/bounded_array.cpp b/doc/samples/bounded_array.cpp index 92614857..200a33ae 100644 --- a/doc/samples/bounded_array.cpp +++ b/doc/samples/bounded_array.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include int main () { diff --git a/doc/samples/compressed_matrix.cpp b/doc/samples/compressed_matrix.cpp index 3d556714..f8852df7 100644 --- a/doc/samples/compressed_matrix.cpp +++ b/doc/samples/compressed_matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/compressed_vector.cpp b/doc/samples/compressed_vector.cpp index 90829ecf..ef05c3a7 100644 --- a/doc/samples/compressed_vector.cpp +++ b/doc/samples/compressed_vector.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/coordinate_matrix.cpp b/doc/samples/coordinate_matrix.cpp index 75786845..70dc00a4 100644 --- a/doc/samples/coordinate_matrix.cpp +++ b/doc/samples/coordinate_matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/coordinate_vector.cpp b/doc/samples/coordinate_vector.cpp index 7b2ea680..2c43176d 100644 --- a/doc/samples/coordinate_vector.cpp +++ b/doc/samples/coordinate_vector.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/hermitian_adaptor.cpp b/doc/samples/hermitian_adaptor.cpp index 1266f90d..1e2bc696 100644 --- a/doc/samples/hermitian_adaptor.cpp +++ b/doc/samples/hermitian_adaptor.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/hermitian_matrix.cpp b/doc/samples/hermitian_matrix.cpp index bba24823..3fb2cb8a 100644 --- a/doc/samples/hermitian_matrix.cpp +++ b/doc/samples/hermitian_matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/identity_matrix.cpp b/doc/samples/identity_matrix.cpp index f3b68361..0dbba804 100644 --- a/doc/samples/identity_matrix.cpp +++ b/doc/samples/identity_matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/map_array.cpp b/doc/samples/map_array.cpp index b3803fe8..5cdc37a4 100644 --- a/doc/samples/map_array.cpp +++ b/doc/samples/map_array.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include int main () { diff --git a/doc/samples/matrix.cpp b/doc/samples/matrix.cpp index d2350dc6..85693b0a 100644 --- a/doc/samples/matrix.cpp +++ b/doc/samples/matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_binary.cpp b/doc/samples/matrix_binary.cpp index e0cd27ab..e4f67bf1 100644 --- a/doc/samples/matrix_binary.cpp +++ b/doc/samples/matrix_binary.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_binary_scalar.cpp b/doc/samples/matrix_binary_scalar.cpp index 8a54cfc3..e5df4b56 100644 --- a/doc/samples/matrix_binary_scalar.cpp +++ b/doc/samples/matrix_binary_scalar.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_column.cpp b/doc/samples/matrix_column.cpp index fc685d65..73c7342d 100644 --- a/doc/samples/matrix_column.cpp +++ b/doc/samples/matrix_column.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_column_project.cpp b/doc/samples/matrix_column_project.cpp index 42afde98..542f7b76 100644 --- a/doc/samples/matrix_column_project.cpp +++ b/doc/samples/matrix_column_project.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_matrix_binary.cpp b/doc/samples/matrix_matrix_binary.cpp index e482b814..45b58efc 100644 --- a/doc/samples/matrix_matrix_binary.cpp +++ b/doc/samples/matrix_matrix_binary.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_matrix_solve.cpp b/doc/samples/matrix_matrix_solve.cpp index 6011d2e9..7b92c6d3 100644 --- a/doc/samples/matrix_matrix_solve.cpp +++ b/doc/samples/matrix_matrix_solve.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_range.cpp b/doc/samples/matrix_range.cpp index 21200481..afa3f9aa 100644 --- a/doc/samples/matrix_range.cpp +++ b/doc/samples/matrix_range.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_range_project.cpp b/doc/samples/matrix_range_project.cpp index f9cda6ac..3bb47e72 100644 --- a/doc/samples/matrix_range_project.cpp +++ b/doc/samples/matrix_range_project.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_row.cpp b/doc/samples/matrix_row.cpp index 66a450c7..b15c3f21 100644 --- a/doc/samples/matrix_row.cpp +++ b/doc/samples/matrix_row.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_row_project.cpp b/doc/samples/matrix_row_project.cpp index 836f8f13..e36ee941 100644 --- a/doc/samples/matrix_row_project.cpp +++ b/doc/samples/matrix_row_project.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_slice.cpp b/doc/samples/matrix_slice.cpp index 22a756c1..cb484892 100644 --- a/doc/samples/matrix_slice.cpp +++ b/doc/samples/matrix_slice.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_slice_project.cpp b/doc/samples/matrix_slice_project.cpp index 1207f504..18a11986 100644 --- a/doc/samples/matrix_slice_project.cpp +++ b/doc/samples/matrix_slice_project.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_unary.cpp b/doc/samples/matrix_unary.cpp index f810eb16..000e6584 100644 --- a/doc/samples/matrix_unary.cpp +++ b/doc/samples/matrix_unary.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_vector_binary.cpp b/doc/samples/matrix_vector_binary.cpp index 6bb129f7..39e4edf6 100644 --- a/doc/samples/matrix_vector_binary.cpp +++ b/doc/samples/matrix_vector_binary.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_vector_range.cpp b/doc/samples/matrix_vector_range.cpp index 4bc2769f..b528980f 100644 --- a/doc/samples/matrix_vector_range.cpp +++ b/doc/samples/matrix_vector_range.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_vector_slice.cpp b/doc/samples/matrix_vector_slice.cpp index acad1bb9..5243c492 100644 --- a/doc/samples/matrix_vector_slice.cpp +++ b/doc/samples/matrix_vector_slice.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/matrix_vector_solve.cpp b/doc/samples/matrix_vector_solve.cpp index 991164ea..1f432482 100644 --- a/doc/samples/matrix_vector_solve.cpp +++ b/doc/samples/matrix_vector_solve.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/range.cpp b/doc/samples/range.cpp index 38595289..3d891c00 100644 --- a/doc/samples/range.cpp +++ b/doc/samples/range.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include int main () { diff --git a/doc/samples/slice.cpp b/doc/samples/slice.cpp index 6fc68227..1a57c6c2 100644 --- a/doc/samples/slice.cpp +++ b/doc/samples/slice.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include int main () { diff --git a/doc/samples/sparse_matrix.cpp b/doc/samples/sparse_matrix.cpp index 5cdab2a0..84d4fc6b 100644 --- a/doc/samples/sparse_matrix.cpp +++ b/doc/samples/sparse_matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/sparse_vector.cpp b/doc/samples/sparse_vector.cpp index 3dd646a0..f130d5bd 100644 --- a/doc/samples/sparse_vector.cpp +++ b/doc/samples/sparse_vector.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/symmetric_adaptor.cpp b/doc/samples/symmetric_adaptor.cpp index 3ad826b0..35924a88 100644 --- a/doc/samples/symmetric_adaptor.cpp +++ b/doc/samples/symmetric_adaptor.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/symmetric_matrix.cpp b/doc/samples/symmetric_matrix.cpp index 176310e2..28addc34 100644 --- a/doc/samples/symmetric_matrix.cpp +++ b/doc/samples/symmetric_matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/triangular_adaptor.cpp b/doc/samples/triangular_adaptor.cpp index d326a7bd..845c4aa3 100644 --- a/doc/samples/triangular_adaptor.cpp +++ b/doc/samples/triangular_adaptor.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/triangular_matrix.cpp b/doc/samples/triangular_matrix.cpp index d924721b..7ec4c6e3 100644 --- a/doc/samples/triangular_matrix.cpp +++ b/doc/samples/triangular_matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/unbounded_array.cpp b/doc/samples/unbounded_array.cpp index b5257278..18f7bbf7 100644 --- a/doc/samples/unbounded_array.cpp +++ b/doc/samples/unbounded_array.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include int main () { diff --git a/doc/samples/unit_vector.cpp b/doc/samples/unit_vector.cpp index 67b571c0..222a8cad 100644 --- a/doc/samples/unit_vector.cpp +++ b/doc/samples/unit_vector.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector.cpp b/doc/samples/vector.cpp index e24c8630..f9bdfa19 100644 --- a/doc/samples/vector.cpp +++ b/doc/samples/vector.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector_binary.cpp b/doc/samples/vector_binary.cpp index e179795d..d664c1d4 100644 --- a/doc/samples/vector_binary.cpp +++ b/doc/samples/vector_binary.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector_binary_outer.cpp b/doc/samples/vector_binary_outer.cpp index 75aa6046..42fa2569 100644 --- a/doc/samples/vector_binary_outer.cpp +++ b/doc/samples/vector_binary_outer.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector_binary_redux.cpp b/doc/samples/vector_binary_redux.cpp index 00082672..754c6154 100644 --- a/doc/samples/vector_binary_redux.cpp +++ b/doc/samples/vector_binary_redux.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include int main () { diff --git a/doc/samples/vector_binary_scalar.cpp b/doc/samples/vector_binary_scalar.cpp index b87802d5..1d2bdebe 100644 --- a/doc/samples/vector_binary_scalar.cpp +++ b/doc/samples/vector_binary_scalar.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector_range.cpp b/doc/samples/vector_range.cpp index eaf72b24..639120e5 100644 --- a/doc/samples/vector_range.cpp +++ b/doc/samples/vector_range.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector_range_project.cpp b/doc/samples/vector_range_project.cpp index 2e02fb7b..52e36ad8 100644 --- a/doc/samples/vector_range_project.cpp +++ b/doc/samples/vector_range_project.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector_slice.cpp b/doc/samples/vector_slice.cpp index bf259c41..ae84210c 100644 --- a/doc/samples/vector_slice.cpp +++ b/doc/samples/vector_slice.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector_slice_project.cpp b/doc/samples/vector_slice_project.cpp index edf4f724..e87821b6 100644 --- a/doc/samples/vector_slice_project.cpp +++ b/doc/samples/vector_slice_project.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector_unary.cpp b/doc/samples/vector_unary.cpp index 1e6c04f8..9a7d93ca 100644 --- a/doc/samples/vector_unary.cpp +++ b/doc/samples/vector_unary.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/vector_unary_redux.cpp b/doc/samples/vector_unary_redux.cpp index 2e0689e3..850b2af3 100644 --- a/doc/samples/vector_unary_redux.cpp +++ b/doc/samples/vector_unary_redux.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include int main () { diff --git a/doc/samples/zero_matrix.cpp b/doc/samples/zero_matrix.cpp index 495fb4a9..59de927d 100644 --- a/doc/samples/zero_matrix.cpp +++ b/doc/samples/zero_matrix.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/doc/samples/zero_vector.cpp b/doc/samples/zero_vector.cpp index cf0c4d92..e4329d2d 100644 --- a/doc/samples/zero_vector.cpp +++ b/doc/samples/zero_vector.cpp @@ -1,3 +1,19 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + #include #include diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index 47daa01c..0f3c438b 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -1082,6 +1082,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type element (size_type i, size_type size1, size_type j, size_type size2) { + // Guarding against overflow. + BOOST_UBLAS_CHECK ((size1 * size2) / size1 == size2, bad_size ()); BOOST_UBLAS_CHECK (i < size1, bad_index ()); BOOST_UBLAS_CHECK (j < size2, bad_index ()); return i * size2 + j; @@ -1089,6 +1091,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type address (size_type i, size_type size1, size_type j, size_type size2) { + // Guarding against overflow. + BOOST_UBLAS_CHECK ((size1 * size2) / size1 == size2, bad_size ()); BOOST_UBLAS_CHECK (i <= size1, bad_index ()); BOOST_UBLAS_CHECK (j <= size2, bad_index ()); return i * size2 + j; @@ -1238,6 +1242,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type element (size_type i, size_type size1, size_type j, size_type size2) { + // Guarding against overflow. + BOOST_UBLAS_CHECK ((size1 * size2) / size1 == size2, bad_size ()); BOOST_UBLAS_CHECK (i < size1, bad_index ()); BOOST_UBLAS_CHECK (j < size2, bad_index ()); return i + j * size1; @@ -1245,6 +1251,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type address (size_type i, size_type size1, size_type j, size_type size2) { + // Guarding against overflow. + BOOST_UBLAS_CHECK ((size1 * size2) / size1 == size2, bad_size ()); BOOST_UBLAS_CHECK (i <= size1, bad_index ()); BOOST_UBLAS_CHECK (j <= size2, bad_index ()); return i + j * size1; diff --git a/include/boost/numeric/ublas/hermitian.hpp b/include/boost/numeric/ublas/hermitian.hpp index 1ea21765..47444a04 100644 --- a/include/boost/numeric/ublas/hermitian.hpp +++ b/include/boost/numeric/ublas/hermitian.hpp @@ -1298,7 +1298,7 @@ namespace boost { namespace numeric { namespace ublas { // Assignment BOOST_UBLAS_INLINE hermitian_adaptor &operator = (const hermitian_adaptor &m) { - matrix_assign (scalar_assign (), *this, m); + matrix_assign (scalar_assign (), *this, m, functor_type ()); return *this; } BOOST_UBLAS_INLINE @@ -1309,37 +1309,37 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE hermitian_adaptor &operator = (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, matrix (ae)); + matrix_assign (scalar_assign (), *this, matrix (ae), functor_type ()); return *this; } template BOOST_UBLAS_INLINE hermitian_adaptor &assign (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae, functor_type ()); return *this; } template BOOST_UBLAS_INLINE hermitian_adaptor& operator += (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, matrix (*this + ae)); + matrix_assign (scalar_assign (), *this, matrix (*this + ae), functor_type ()); return *this; } template BOOST_UBLAS_INLINE hermitian_adaptor &plus_assign (const matrix_expression &ae) { - matrix_assign (scalar_plus_assign (), *this, ae); + matrix_assign (scalar_plus_assign (), *this, ae, functor_type ()); return *this; } template BOOST_UBLAS_INLINE hermitian_adaptor& operator -= (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, matrix (*this - ae)); + matrix_assign (scalar_assign (), *this, matrix (*this - ae), functor_type ()); return *this; } template BOOST_UBLAS_INLINE hermitian_adaptor &minus_assign (const matrix_expression &ae) { - matrix_assign (scalar_minus_assign (), *this, ae); + matrix_assign (scalar_minus_assign (), *this, ae, functor_type ()); return *this; } template @@ -1369,7 +1369,7 @@ namespace boost { namespace numeric { namespace ublas { // Too unusual semantic. // BOOST_UBLAS_CHECK (this != &m, external_logic ()); if (this != &m) - matrix_swap (scalar_swap (), *this, m); + matrix_swap (scalar_swap (), *this, m, functor_type ()); } #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS BOOST_UBLAS_INLINE diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index bdc17ae1..44e2b136 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -1961,26 +1961,34 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - if (rank == 1) + if (rank == 1) { i = std::max (i, j); + i = std::min (i, j + 1); + } return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - if (rank == 1) + if (rank == 1) { + i = std::max (i, j); i = std::min (i, j + 1); + } return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - if (rank == 1) + if (rank == 1) { j = std::max (j, i); + j = std::min (j, i + 1); + } return const_iterator2 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - if (rank == 1) + if (rank == 1) { + j = std::max (j, i); j = std::min (j, i + 1); + } return const_iterator2 (*this, i, j); } @@ -2405,25 +2413,25 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 find_first1 (int rank, size_type i, size_type j) const { if (rank == 1) - i = std::max (i, size_type (0)); + i = j; return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator1 find_last1 (int rank, size_type i, size_type j) const { if (rank == 1) - i = std::min (i, size_type (0)); + i = j; return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator2 find_first2 (int rank, size_type i, size_type j) const { if (rank == 1) - j = std::max (j, size_type (0)); + j = i; return const_iterator2 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator2 find_last2 (int rank, size_type i, size_type j) const { if (rank == 1) - j = std::min (j, size_type (0)); + j = i; return const_iterator2 (*this, i, j); } diff --git a/include/boost/numeric/ublas/matrix_assign.hpp b/include/boost/numeric/ublas/matrix_assign.hpp index 5e71ca80..93c79212 100644 --- a/include/boost/numeric/ublas/matrix_assign.hpp +++ b/include/boost/numeric/ublas/matrix_assign.hpp @@ -449,7 +449,7 @@ namespace boost { namespace numeric { namespace ublas { template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_assign (const F &f, M &m, const matrix_expression &e, dense_proxy_tag, C c) { + void matrix_assign (const F &f, M &m, const matrix_expression &e, full, dense_proxy_tag, C c) { typedef F functor_type; typedef C orientation_category; #ifdef BOOST_UBLAS_USE_INDEXING @@ -468,19 +468,20 @@ namespace boost { namespace numeric { namespace ublas { #endif } // Packed (proxy) row major case - template + template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_assign (const F &f, M &m, const matrix_expression &e, packed_proxy_tag, row_major_tag) { + void matrix_assign (const F1 &f1, M &m, const matrix_expression &e, const F2 &f2, packed_proxy_tag, row_major_tag) { BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); - typedef F functor_type; + typedef F1 functor1_type; + typedef F2 functor2_type; typedef typename M::difference_type difference_type; typedef typename M::value_type value_type; -#ifdef BOOST_UBLAS_TYPE_CHECK_TOO_STRONG +#ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); indexing_matrix_assign (scalar_assign (), cm, m, row_major_tag ()); - indexing_matrix_assign (functor_type (), cm, e, row_major_tag ()); + indexing_matrix_assign (functor1_type (), cm, e, row_major_tag ()); #endif typename M::iterator1 it1 (m.begin1 ()); typename M::iterator1 it1_end (m.end1 ()); @@ -506,7 +507,7 @@ namespace boost { namespace numeric { namespace ublas { typename M::iterator2 it2_end (it1.end ()); difference_type size2 (it2_end - it2); while (-- size2 >= 0) - functor_type () (*it2, value_type ()), ++ it2; + functor1_type () (*it2, value_type ()), ++ it2; ++ it1; } diff1 += size1; @@ -535,7 +536,7 @@ namespace boost { namespace numeric { namespace ublas { if (size2 > 0) { it2_size -= size2; while (-- size2 >= 0) - functor_type () (*it2, value_type ()), ++ it2; + functor1_type () (*it2, value_type ()), ++ it2; diff2 += size2; } } @@ -543,10 +544,10 @@ namespace boost { namespace numeric { namespace ublas { it2_size -= size2; it2e_size -= size2; while (-- size2 >= 0) - functor_type () (*it2, *it2e), ++ it2, ++ it2e; + functor1_type () (*it2, *it2e), ++ it2, ++ it2e; size2 = it2_size; while (-- size2 >= 0) - functor_type () (*it2, value_type ()), ++ it2; + functor1_type () (*it2, value_type ()), ++ it2; ++ it1, ++ it1e; } size1 = it1_size; @@ -555,28 +556,29 @@ namespace boost { namespace numeric { namespace ublas { typename M::iterator2 it2_end (it1.end ()); difference_type size2 (it2_end - it2); while (-- size2 >= 0) - functor_type () (*it2, value_type ()), ++ it2; + functor1_type () (*it2, value_type ()), ++ it2; ++ it1; } -#ifdef BOOST_UBLAS_TYPE_CHECK_TOO_STRONG +#ifdef BOOST_UBLAS_TYPE_CHECK if (! disable_type_check) BOOST_UBLAS_CHECK (equals (m, cm), external_logic ()); #endif } // Packed (proxy) column major case - template + template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_assign (const F &f, M &m, const matrix_expression &e, packed_proxy_tag, column_major_tag) { + void matrix_assign (const F1 &f1, M &m, const matrix_expression &e, const F2 &f2, packed_proxy_tag, column_major_tag) { BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); - typedef F functor_type; + typedef F1 functor1_type; + typedef F2 functor2_type; typedef typename M::difference_type difference_type; typedef typename M::value_type value_type; -#ifdef BOOST_UBLAS_TYPE_CHECK_TOO_STRONG +#ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); indexing_matrix_assign (scalar_assign (), cm, m, column_major_tag ()); - indexing_matrix_assign (functor_type (), cm, e, column_major_tag ()); + indexing_matrix_assign (functor1_type (), cm, e, column_major_tag ()); #endif typename M::iterator2 it2 (m.begin2 ()); typename M::iterator2 it2_end (m.end2 ()); @@ -602,7 +604,7 @@ namespace boost { namespace numeric { namespace ublas { typename M::iterator1 it1_end (it2.end ()); difference_type size1 (it1_end - it1); while (-- size1 >= 0) - functor_type () (*it1, value_type ()), ++ it1; + functor1_type () (*it1, value_type ()), ++ it1; ++ it2; } diff2 += size2; @@ -631,7 +633,7 @@ namespace boost { namespace numeric { namespace ublas { if (size1 > 0) { it1_size -= size1; while (-- size1 >= 0) - functor_type () (*it1, value_type ()), ++ it1; + functor1_type () (*it1, value_type ()), ++ it1; diff1 += size1; } } @@ -639,10 +641,10 @@ namespace boost { namespace numeric { namespace ublas { it1_size -= size1; it1e_size -= size1; while (-- size1 >= 0) - functor_type () (*it1, *it1e), ++ it1, ++ it1e; + functor1_type () (*it1, *it1e), ++ it1, ++ it1e; size1 = it1_size; while (-- size1 >= 0) - functor_type () (*it1, value_type ()), ++ it1; + functor1_type () (*it1, value_type ()), ++ it1; ++ it2, ++ it2e; } size2 = it2_size; @@ -651,10 +653,10 @@ namespace boost { namespace numeric { namespace ublas { typename M::iterator1 it1_end (it2.end ()); difference_type size1 (it1_end - it1); while (-- size1 >= 0) - functor_type () (*it1, value_type ()), ++ it1; + functor1_type () (*it1, value_type ()), ++ it1; ++ it2; } -#ifdef BOOST_UBLAS_TYPE_CHECK_TOO_STRONG +#ifdef BOOST_UBLAS_TYPE_CHECK if (! disable_type_check) BOOST_UBLAS_CHECK (equals (m, cm), external_logic ()); #endif @@ -663,7 +665,7 @@ namespace boost { namespace numeric { namespace ublas { template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_assign (const F &f, M &m, const matrix_expression &e, sparse_tag, row_major_tag) { + void matrix_assign (const F &f, M &m, const matrix_expression &e, full, sparse_tag, row_major_tag) { BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); typedef F functor_type; @@ -696,7 +698,7 @@ namespace boost { namespace numeric { namespace ublas { template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_assign (const F &f, M &m, const matrix_expression &e, sparse_tag, column_major_tag) { + void matrix_assign (const F &f, M &m, const matrix_expression &e, full, sparse_tag, column_major_tag) { BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); typedef F functor_type; @@ -726,19 +728,20 @@ namespace boost { namespace numeric { namespace ublas { #endif } // Sparse proxy row major case - template + template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_assign (const F &f, M &m, const matrix_expression &e, sparse_proxy_tag, row_major_tag) { + void matrix_assign (const F1 &f1, M &m, const matrix_expression &e, const F2 &f2, sparse_proxy_tag, row_major_tag) { BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); - typedef F functor_type; + typedef F1 functor1_type; + typedef F2 functor2_type; typedef typename M::size_type size_type; typedef typename M::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); indexing_matrix_assign (scalar_assign (), cm, m, row_major_tag ()); - indexing_matrix_assign (functor_type (), cm, e, row_major_tag ()); + indexing_matrix_assign (functor1_type (), cm, e, row_major_tag ()); #endif typename M::iterator1 it1 (m.begin1 ()); typename M::iterator1 it1_end (m.end1 ()); @@ -754,20 +757,26 @@ namespace boost { namespace numeric { namespace ublas { while (it2 != it2_end && it2e != it2e_end) { int compare = it2.index2 () - it2e.index2 (); if (compare == 0) { - functor_type () (*it2, *it2e); + functor1_type () (*it2, *it2e); ++ it2, ++ it2e; } else if (compare < 0) { - functor_type () (*it2, value_type ()); + functor1_type () (*it2, value_type ()); ++ it2; } else if (compare > 0) { #ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2e.index1 ()), index2 (it2e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); - // The proxies could reference the same container. - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + // The proxies could reference the same container. + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + } else { + ++ it2e; + } +#else + ++ it2e; #endif } } @@ -776,14 +785,18 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2e.index1 ()), index2 (it2e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + } else { + ++ it2e; + } } #endif while (it2 != it2_end) { - functor_type () (*it2, value_type ()); + functor1_type () (*it2, value_type ()); ++ it2; } ++ it1, ++ it1e; @@ -791,7 +804,7 @@ namespace boost { namespace numeric { namespace ublas { typename M::iterator2 it2 (it1.begin ()); typename M::iterator2 it2_end (it1.end ()); while (it2 != it2_end) { - functor_type () (*it2, value_type ()); + functor1_type () (*it2, value_type ()); ++ it2; } ++ it1; @@ -805,10 +818,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2e.index1 ()), index2 (it2e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + } else { + ++ it2e; + } } #endif ++ it1e; @@ -824,10 +841,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2e.index1 ()), index2 (it2e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + } else { + ++ it2e; + } } ++ it1e; } @@ -836,7 +857,7 @@ namespace boost { namespace numeric { namespace ublas { typename M::iterator2 it2 (it1.begin ()); typename M::iterator2 it2_end (it1.end ()); while (it2 != it2_end) { - functor_type () (*it2, value_type ()); + functor1_type () (*it2, value_type ()); ++ it2; } ++ it1; @@ -847,19 +868,20 @@ namespace boost { namespace numeric { namespace ublas { #endif } // Sparse proxy column major case - template + template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_assign (const F &f, M &m, const matrix_expression &e, sparse_proxy_tag, column_major_tag) { + void matrix_assign (const F1 &f1, M &m, const matrix_expression &e, const F2 &f2, sparse_proxy_tag, column_major_tag) { BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); - typedef F functor_type; + typedef F1 functor1_type; + typedef F2 functor2_type; typedef typename M::size_type size_type; typedef typename M::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); indexing_matrix_assign (scalar_assign (), cm, m, column_major_tag ()); - indexing_matrix_assign (functor_type (), cm, e, column_major_tag ()); + indexing_matrix_assign (functor1_type (), cm, e, column_major_tag ()); #endif typename M::iterator2 it2 (m.begin2 ()); typename M::iterator2 it2_end (m.end2 ()); @@ -875,20 +897,26 @@ namespace boost { namespace numeric { namespace ublas { while (it1 != it1_end && it1e != it1e_end) { int compare = it1.index1 () - it1e.index1 (); if (compare == 0) { - functor_type () (*it1, *it1e); + functor1_type () (*it1, *it1e); ++ it1, ++ it1e; } else if (compare < 0) { - functor_type () (*it1, value_type ()); + functor1_type () (*it1, value_type ()); ++ it1; } else if (compare > 0) { #ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1e.index1 ()), index2 (it1e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); - // The proxies could reference the same container. - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + // The proxies could reference the same container. + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + } else { + ++ it1e; + } +#else + ++ it1e; #endif } } @@ -897,14 +925,18 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1e.index1 ()), index2 (it1e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + } else { + ++ it1e; + } } #endif while (it1 != it1_end) { - functor_type () (*it1, value_type ()); + functor1_type () (*it1, value_type ()); ++ it1; } ++ it2, ++ it2e; @@ -912,7 +944,7 @@ namespace boost { namespace numeric { namespace ublas { typename M::iterator1 it1 (it2.begin ()); typename M::iterator1 it1_end (it2.end ()); while (it1 != it1_end) { - functor_type () (*it1, value_type ()); + functor1_type () (*it1, value_type ()); ++ it1; } ++ it2; @@ -926,10 +958,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1e.index1 ()), index2 (it1e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + } else { + ++ it1e; + } } #endif ++ it2e; @@ -945,10 +981,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1e.index1 ()), index2 (it1e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + } else { + ++ it1e; + } } ++ it2e; } @@ -957,7 +997,7 @@ namespace boost { namespace numeric { namespace ublas { typename M::iterator1 it1 (it2.begin ()); typename M::iterator1 it1_end (it2.end ()); while (it1 != it1_end) { - functor_type () (*it1, value_type ()); + functor1_type () (*it1, value_type ()); ++ it1; } ++ it2; @@ -980,7 +1020,21 @@ namespace boost { namespace numeric { namespace ublas { // FIXME: can't we improve the dispatch here? // typedef typename E::orientation_category orientation_category; typedef typename M::orientation_category orientation_category; - matrix_assign (functor_type (), m, e, storage_category (), orientation_category ()); + matrix_assign (functor_type (), m, e, full (), storage_category (), orientation_category ()); + } + template + BOOST_UBLAS_INLINE + void matrix_assign (const F1 &f1, M &m, const matrix_expression &e, const F2 &f2) { + typedef F1 functor1_type; + typedef F2 functor2_type; + typedef typename matrix_assign_traits::storage_category storage_category; + // FIXME: can't we improve the dispatch here? + // typedef typename E::orientation_category orientation_category; + typedef typename M::orientation_category orientation_category; + matrix_assign (functor1_type (), m, e, functor2_type (), storage_category (), orientation_category ()); } template @@ -1002,7 +1056,7 @@ namespace boost { namespace numeric { namespace ublas { template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_swap (const F &f, M &m, matrix_expression &e, dense_proxy_tag, row_major_tag) { + void matrix_swap (const F &f, M &m, matrix_expression &e, full, dense_proxy_tag, row_major_tag) { typedef F functor_type; typedef typename M::size_type size_type; typedef typename M::difference_type difference_type; @@ -1022,7 +1076,7 @@ namespace boost { namespace numeric { namespace ublas { template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_swap (const F &f, M &m, matrix_expression &e, dense_proxy_tag, column_major_tag) { + void matrix_swap (const F &f, M &m, matrix_expression &e, full, dense_proxy_tag, column_major_tag) { typedef F functor_type; typedef typename M::size_type size_type; typedef typename M::difference_type difference_type; @@ -1039,11 +1093,12 @@ namespace boost { namespace numeric { namespace ublas { } } // Packed (proxy) row major case - template + template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_swap (const F &f, M &m, matrix_expression &e, packed_proxy_tag, row_major_tag) { - typedef F functor_type; + void matrix_swap (const F1 &f1, M &m, matrix_expression &e, const F2 &f2, packed_proxy_tag, row_major_tag) { + typedef F1 functor1_type; + typedef F2 functor2_type; typedef typename M::size_type size_type; typedef typename M::difference_type difference_type; typename M::iterator1 it1 (m.begin1 ()); @@ -1054,16 +1109,17 @@ namespace boost { namespace numeric { namespace ublas { typename E::iterator2 it2e (it1e.begin ()); difference_type size2 (BOOST_UBLAS_SAME (it1.end () - it2, it1e.end () - it2e)); while (-- size2 >= 0) - functor_type () (*it2, *it2e), ++ it2, ++ it2e; + functor1_type () (*it2, *it2e), ++ it2, ++ it2e; ++ it1, ++ it1e; } } // Packed (proxy) column major case - template + template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_swap (const F &f, M &m, matrix_expression &e, packed_proxy_tag, column_major_tag) { - typedef F functor_type; + void matrix_swap (const F1 &f1, M &m, matrix_expression &e, const F2 &f2, packed_proxy_tag, column_major_tag) { + typedef F1 functor1_type; + typedef F2 functor2_type; typedef typename M::size_type size_type; typedef typename M::difference_type difference_type; typename M::iterator2 it2 (m.begin2 ()); @@ -1074,18 +1130,19 @@ namespace boost { namespace numeric { namespace ublas { typename E::iterator1 it1e (it2e.begin ()); difference_type size1 (BOOST_UBLAS_SAME (it2.end () - it1, it2e.end () - it1e)); while (-- size1 >= 0) - functor_type () (*it1, *it1e), ++ it1, ++ it1e; + functor1_type () (*it1, *it1e), ++ it1, ++ it1e; ++ it2, ++ it2e; } } // Sparse (proxy) row major case - template + template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_swap (const F &f, M &m, matrix_expression &e, sparse_proxy_tag, row_major_tag) { + void matrix_swap (const F1 &f1, M &m, matrix_expression &e, const F2 &f2, sparse_proxy_tag, row_major_tag) { BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); - typedef F functor_type; + typedef F1 functor1_type; + typedef F2 functor2_type; typedef typename M::size_type size_type; typedef typename M::value_type value_type; typename M::iterator1 it1 (m.begin1 ()); @@ -1102,27 +1159,39 @@ namespace boost { namespace numeric { namespace ublas { while (it2 != it2_end && it2e != it2e_end) { int compare = it2.index2 () - it2e.index2 (); if (compare == 0) { - functor_type () (*it2, *it2e); + functor1_type () (*it2, *it2e); ++ it2, ++ it2e; } else if (compare < 0) { #ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2.index1 ()), index2 (it2.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); - // The proxies could reference the same container. - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + // The proxies could reference the same container. + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + } else { + ++ it2; + } +#else + ++ it2; #endif } else if (compare > 0) { #ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2e.index1 ()), index2 (it2e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); - // The proxies could reference the same container. - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + // The proxies could reference the same container. + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + } else { + ++ it2e; + } +#else + ++ it2e; #endif } } @@ -1131,19 +1200,27 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2e.index1 ()), index2 (it2e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + } else { + ++ it2e; + } } while (it2 != it2_end) { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2.index1 ()), index2 (it2.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + } else { + ++ it2; + } } #endif ++ it1, ++ it1e; @@ -1157,10 +1234,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2.index1 ()), index2 (it2.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + } else { + ++ it2; + } } #endif ++ it1; @@ -1174,10 +1255,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2e.index1 ()), index2 (it2e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + } else { + ++ it2e; + } } #endif ++ it1e; @@ -1193,10 +1278,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2e.index1 ()), index2 (it2e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + } else { + ++ it2e; + } } ++ it1e; } @@ -1209,23 +1298,28 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it2.index1 ()), index2 (it2.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); - restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ()); + restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ()); + } else { + ++ it2; + } } ++ it1; } #endif } // Sparse (proxy) column major case - template + template // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - void matrix_swap (const F &f, M &m, matrix_expression &e, sparse_proxy_tag, column_major_tag) { + void matrix_swap (const F1 &f1, M &m, matrix_expression &e, const F2 &f2, sparse_proxy_tag, column_major_tag) { BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); - typedef F functor_type; + typedef F1 functor1_type; + typedef F2 functor2_type; typedef typename M::size_type size_type; typedef typename M::value_type value_type; typename M::iterator2 it2 (m.begin2 ()); @@ -1242,27 +1336,39 @@ namespace boost { namespace numeric { namespace ublas { while (it1 != it1_end && it1e != it1e_end) { int compare = it1.index1 () - it1e.index1 (); if (compare == 0) { - functor_type () (*it1, *it1e); + functor1_type () (*it1, *it1e); ++ it1, ++ it1e; } else if (compare < 0) { #ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1.index1 ()), index2 (it1.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); - // The proxies could reference the same container. - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + // The proxies could reference the same container. + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + } else { + ++ it1; + } +#else + ++ it1; #endif } else if (compare > 0) { #ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1e.index1 ()), index2 (it1e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); - // The proxies could reference the same container. - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + // The proxies could reference the same container. + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + } else { + ++ it1e; + } +#else + ++ it1e; #endif } } @@ -1271,19 +1377,27 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1e.index1 ()), index2 (it1e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + } else { + ++ it1e; + } } while (it1 != it1_end) { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1.index1 ()), index2 (it1.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + } else { + ++ it1; + } } #endif ++ it2, ++ it2e; @@ -1297,10 +1411,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1.index1 ()), index2 (it1.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + } else { + ++ it1; + } } #endif ++ it2; @@ -1314,10 +1432,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1e.index1 ()), index2 (it1e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + } else { + ++ it1e; + } } #endif ++ it2e; @@ -1333,10 +1455,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1e.index1 ()), index2 (it1e.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + } else { + ++ it1e; + } } ++ it2e; } @@ -1349,10 +1475,14 @@ namespace boost { namespace numeric { namespace ublas { // Sparse proxies don't need to be conformant. // Thanks to Michael Stevens for suggesting this. size_type index1 (it1.index1 ()), index2 (it1.index2 ()); - functor_type () (m (index1, index2), e () (index1, index2)); - // The proxies could reference the same container. - restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); - restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + if (functor2_type::other (index1, index2)) { + functor1_type () (m (index1, index2), e () (index1, index2)); + // The proxies could reference the same container. + restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ()); + restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ()); + } else { + ++ it1; + } } ++ it2; } @@ -1370,7 +1500,20 @@ namespace boost { namespace numeric { namespace ublas { // FIXME: can't we improve the dispatch here? // typedef typename E::orientation_category orientation_category; typedef typename M::orientation_category orientation_category; - matrix_swap (functor_type (), m, e, storage_category (), orientation_category ()); + matrix_swap (functor_type (), m, e, full (), storage_category (), orientation_category ()); + } + template + BOOST_UBLAS_INLINE + void matrix_swap (const F1 &f1, M &m, matrix_expression &e, const F2 &f2) { + typedef F1 functor1_type; + typedef F2 functor2_type; + typedef typename matrix_swap_traits::storage_category storage_category; + // FIXME: can't we improve the dispatch here? + // typedef typename E::orientation_category orientation_category; + typedef typename M::orientation_category orientation_category; + matrix_swap (functor1_type (), m, e, functor2_type (), storage_category (), orientation_category ()); } }}} diff --git a/include/boost/numeric/ublas/symmetric.hpp b/include/boost/numeric/ublas/symmetric.hpp index 819f4e58..d6c2afb1 100644 --- a/include/boost/numeric/ublas/symmetric.hpp +++ b/include/boost/numeric/ublas/symmetric.hpp @@ -1060,7 +1060,7 @@ namespace boost { namespace numeric { namespace ublas { // Assignment BOOST_UBLAS_INLINE symmetric_adaptor &operator = (const symmetric_adaptor &m) { - matrix_assign (scalar_assign (), *this, m); + matrix_assign (scalar_assign (), *this, m, functor_type ()); return *this; } BOOST_UBLAS_INLINE @@ -1071,37 +1071,37 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE symmetric_adaptor &operator = (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, matrix (ae)); + matrix_assign (scalar_assign (), *this, matrix (ae), functor_type ()); return *this; } template BOOST_UBLAS_INLINE symmetric_adaptor &assign (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae, functor_type ()); return *this; } template BOOST_UBLAS_INLINE symmetric_adaptor& operator += (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, matrix (*this + ae)); + matrix_assign (scalar_assign (), *this, matrix (*this + ae), functor_type ()); return *this; } template BOOST_UBLAS_INLINE symmetric_adaptor &plus_assign (const matrix_expression &ae) { - matrix_assign (scalar_plus_assign (), *this, ae); + matrix_assign (scalar_plus_assign (), *this, ae, functor_type ()); return *this; } template BOOST_UBLAS_INLINE symmetric_adaptor& operator -= (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, matrix (*this - ae)); + matrix_assign (scalar_assign (), *this, matrix (*this - ae), functor_type ()); return *this; } template BOOST_UBLAS_INLINE symmetric_adaptor &minus_assign (const matrix_expression &ae) { - matrix_assign (scalar_minus_assign (), *this, ae); + matrix_assign (scalar_minus_assign (), *this, ae, functor_type ()); return *this; } template @@ -1123,7 +1123,7 @@ namespace boost { namespace numeric { namespace ublas { // Too unusual semantic // BOOST_UBLAS_CHECK (this != &m, external_logic ()); if (this != &m) - matrix_swap (scalar_swap (), *this, m); + matrix_swap (scalar_swap (), *this, m, functor_type ()); } #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS BOOST_UBLAS_INLINE diff --git a/include/boost/numeric/ublas/triangular.hpp b/include/boost/numeric/ublas/triangular.hpp index 1b8cef1e..a513bd79 100644 --- a/include/boost/numeric/ublas/triangular.hpp +++ b/include/boost/numeric/ublas/triangular.hpp @@ -1812,10 +1812,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e1 ().size2 () == e2.size (), bad_size ()); size_type size = e2.size (); for (size_type n = 0; n < size; ++ n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e2 (n) /= e1 () (n, n); - for (size_type m = n + 1; m < size; ++ m) - e2 (m) -= e1 () (m, n) * t; + if (t != value_type ()) { + for (size_type m = n + 1; m < size; ++ m) + e2 (m) -= e1 () (m, n) * t; + } } } // Packed (proxy) case @@ -1831,13 +1838,20 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e1 ().size2 () == e2.size (), bad_size ()); size_type size = e2.size (); for (size_type n = 0; n < size; ++ n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e2 (n) /= e1 () (n, n); - typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); - typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); - difference_type m (it1e1_end - it1e1); - while (-- m >= 0) - e2 (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; + if (t != value_type ()) { + typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); + typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); + difference_type m (it1e1_end - it1e1); + while (-- m >= 0) + e2 (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; + } } } // Sparse (proxy) case @@ -1853,12 +1867,19 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e1 ().size2 () == e2.size (), bad_size ()); size_type size = e2.size (); for (size_type n = 0; n < size; ++ n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e2 (n) /= e1 () (n, n); - typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); - typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); - while (it1e1 != it1e1_end) - e2 (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; + if (t != value_type ()) { + typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); + typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); + while (it1e1 != it1e1_end) + e2 (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; + } } } // Dispatcher @@ -1883,10 +1904,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e1 ().size2 () == e2.size (), bad_size ()); size_type size = e2.size (); for (difference_type n = size - 1; n >= 0; -- n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e2 (n) /= e1 () (n, n); - for (difference_type m = n - 1; m >= 0; -- m) - e2 (m) -= e1 () (m, n) * t; + if (t != value_type ()) { + for (difference_type m = n - 1; m >= 0; -- m) + e2 (m) -= e1 () (m, n) * t; + } } } // Packed (proxy) case @@ -1902,13 +1930,20 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e1 ().size2 () == e2.size (), bad_size ()); size_type size = e2.size (); for (difference_type n = size - 1; n >= 0; -- n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e2 (n) /= e1 () (n, n); - typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); - typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); - difference_type m (it1e1_rend - it1e1); - while (-- m >= 0) - e2 (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; + if (t != value_type ()) { + typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); + typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); + difference_type m (it1e1_rend - it1e1); + while (-- m >= 0) + e2 (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; + } } } // Sparse (proxy) case @@ -1924,12 +1959,19 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e1 ().size2 () == e2.size (), bad_size ()); size_type size = e2.size (); for (difference_type n = size - 1; n >= 0; -- n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e2 (n) /= e1 () (n, n); - typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); - typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); - while (it1e1 != it1e1_rend) - e2 (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; + if (t != value_type ()) { + typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); + typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); + while (it1e1 != it1e1_rend) + e2 (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; + } } } // Dispatcher @@ -1946,7 +1988,7 @@ namespace boost { namespace numeric { namespace ublas { void inplace_solve (const matrix_expression &e1, vector_expression &e2, C) { - inplace_solve (e1, e2, C (), vector_tag ()); + inplace_solve (e1, e2 (), C (), vector_tag ()); } template BOOST_UBLAS_INLINE @@ -1972,10 +2014,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e2 ().size1 () == e2 ().size2 (), bad_size ()); size_type size = e1.size (); for (size_type n = 0; n < size; ++ n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e2 () (n, n) != value_type (), singular ()); +#else + if (e2 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e1 (n) /= e2 () (n, n); - for (size_type m = n + 1; m < size; ++ m) - e1 (m) -= t * e2 () (n, m); + if (t != value_type ()) { + for (size_type m = n + 1; m < size; ++ m) + e1 (m) -= t * e2 () (n, m); + } } } // Packed (proxy) case @@ -1991,15 +2040,22 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e2 ().size1 () == e2 ().size2 (), bad_size ()); size_type size = e1.size (); for (size_type n = 0; n < size; ++ n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e2 () (n, n) != value_type (), singular ()); +#else + if (e2 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e1 (n) /= e2 () (n, n); - typename E1::iterator ite1 (e1.find_first (n + 1)); - typename E1::iterator ite1_end (e1.find_first (e2 ().size ())); - typename E2::const_iterator2 it2e2 (e2 ().find_first2 (1, n, n + 1)); - typename E2::const_iterator2 it2e2_end (e2 ().find_first2 (1, n, e2 ().size2 ())); - difference_type m (it2e2_end - it2e2); - while (-- m >= 0) - e1 (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; + if (t != value_type ()) { + typename E1::iterator ite1 (e1.find_first (n + 1)); + typename E1::iterator ite1_end (e1.find_first (e2 ().size ())); + typename E2::const_iterator2 it2e2 (e2 ().find_first2 (1, n, n + 1)); + typename E2::const_iterator2 it2e2_end (e2 ().find_first2 (1, n, e2 ().size2 ())); + difference_type m (it2e2_end - it2e2); + while (-- m >= 0) + e1 (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; + } } } // Sparse (proxy) case @@ -2015,12 +2071,19 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e2 ().size1 () == e2 ().size2 (), bad_size ()); size_type size = e1.size (); for (size_type n = 0; n < size; ++ n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e2 () (n, n) != value_type (), singular ()); +#else + if (e2 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e1 (n) /= e2 () (n, n); - typename E2::const_iterator2 it2e2 (e2 ().find_first2 (1, n, n + 1)); - typename E2::const_iterator2 it2e2_end (e2 ().find_first2 (1, n, e2 ().size2 ())); - while (it2e2 != it2e2_end) - e1 (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; + if (t != value_type ()) { + typename E2::const_iterator2 it2e2 (e2 ().find_first2 (1, n, n + 1)); + typename E2::const_iterator2 it2e2_end (e2 ().find_first2 (1, n, e2 ().size2 ())); + while (it2e2 != it2e2_end) + e1 (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; + } } } // Dispatcher @@ -2045,10 +2108,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e2.size1 () == e2.size2 (), bad_size ()); size_type size = e1.size (); for (difference_type n = size - 1; n >= 0; -- n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e2 (n, n) != value_type (), singular ()); +#else + if (e2 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e1 (n) /= e2 (n, n); - for (difference_type m = n - 1; m >= 0; -- m) - e1 (m) -= t * e2 (n, m); + if (t != value_type ()) { + for (difference_type m = n - 1; m >= 0; -- m) + e1 (m) -= t * e2 (n, m); + } } } // Packed (proxy) case @@ -2064,13 +2134,20 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e2.size1 () == e2.size2 (), bad_size ()); size_type size = e1.size (); for (difference_type n = size - 1; n >= 0; -- n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e2 (n, n) != value_type (), singular ()); +#else + if (e2 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e1 (n) /= e2 (n, n); - typename E2::const_reverse_iterator2 it2e2 (e2 ().find_first2 (1, n, n)); - typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find_first2 (1, n, 0)); - difference_type m (it2e2_rend - it2e2); - while (-- m >= 0) - e1 (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; + if (t != value_type ()) { + typename E2::const_reverse_iterator2 it2e2 (e2 ().find_first2 (1, n, n)); + typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find_first2 (1, n, 0)); + difference_type m (it2e2_rend - it2e2); + while (-- m >= 0) + e1 (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; + } } } // Sparse (proxy) case @@ -2086,12 +2163,19 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (e2.size1 () == e2.size2 (), bad_size ()); size_type size = e1.size (); for (difference_type n = size - 1; n >= 0; -- n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e2 (n, n) != value_type (), singular ()); +#else + if (e2 () (n, n) == value_type ()) + singular.raise (); +#endif value_type t = e1 (n) /= e2 (n, n); - typename E2::const_reverse_iterator2 it2e2 (e2 ().find_first2 (1, n, n)); - typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find_first2 (1, n, 0)); - while (it2e2 != it2e2_rend) - e1 (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; + if (t != value_type ()) { + typename E2::const_reverse_iterator2 it2e2 (e2 ().find_first2 (1, n, n)); + typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find_first2 (1, n, 0)); + while (it2e2 != it2e2_rend) + e1 (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; + } } } // Dispatcher @@ -2108,7 +2192,7 @@ namespace boost { namespace numeric { namespace ublas { void inplace_solve (vector_expression &e1, const matrix_expression &e2, C) { - inplace_solve (e1, e2, vector_tag (), C ()); + inplace_solve (e1 (), e2, vector_tag (), C ()); } template BOOST_UBLAS_INLINE @@ -2145,11 +2229,18 @@ namespace boost { namespace numeric { namespace ublas { size_type size1 = e2.size1 (); size_type size2 = e2.size2 (); for (size_type n = 0; n < size1; ++ n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif for (size_type l = 0; l < size2; ++ l) { value_type t = e2 (n, l) /= e1 () (n, n); - for (size_type m = n + 1; m < size1; ++ m) - e2 (m, l) -= e1 () (m, n) * t; + if (t != value_type ()) { + for (size_type m = n + 1; m < size1; ++ m) + e2 (m, l) -= e1 () (m, n) * t; + } } } } @@ -2167,14 +2258,21 @@ namespace boost { namespace numeric { namespace ublas { size_type size1 = e2.size1 (); size_type size2 = e2.size2 (); for (size_type n = 0; n < size1; ++ n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif for (size_type l = 0; l < size2; ++ l) { value_type t = e2 (n, l) /= e1 () (n, n); - typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); - typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); - difference_type m (it1e1_end - it1e1); - while (-- m >= 0) - e2 (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; + if (t != value_type ()) { + typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); + typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); + difference_type m (it1e1_end - it1e1); + while (-- m >= 0) + e2 (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; + } } } } @@ -2192,13 +2290,20 @@ namespace boost { namespace numeric { namespace ublas { size_type size1 = e2.size1 (); size_type size2 = e2.size2 (); for (size_type n = 0; n < size1; ++ n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif for (size_type l = 0; l < size2; ++ l) { value_type t = e2 (n, l) /= e1 () (n, n); - typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); - typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); - while (it1e1 != it1e1_end) - e2 (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; + if (t != value_type ()) { + typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); + typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); + while (it1e1 != it1e1_end) + e2 (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; + } } } } @@ -2225,11 +2330,18 @@ namespace boost { namespace numeric { namespace ublas { size_type size1 = e2.size1 (); size_type size2 = e2.size2 (); for (difference_type n = size1 - 1; n >= 0; -- n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif for (difference_type l = size2 - 1; l >= 0; -- l) { value_type t = e2 (n, l) /= e1 () (n, n); - for (difference_type m = n - 1; m >= 0; -- m) - e2 (m, l) -= e1 () (m, n) * t; + if (t != value_type ()) { + for (difference_type m = n - 1; m >= 0; -- m) + e2 (m, l) -= e1 () (m, n) * t; + } } } } @@ -2247,14 +2359,21 @@ namespace boost { namespace numeric { namespace ublas { size_type size1 = e2.size1 (); size_type size2 = e2.size2 (); for (difference_type n = size1 - 1; n >= 0; -- n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif for (difference_type l = size2 - 1; l >= 0; -- l) { value_type t = e2 (n, l) /= e1 () (n, n); - typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); - typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); - difference_type m (it1e1_rend - it1e1); - while (-- m >= 0) - e2 (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; + if (t != value_type ()) { + typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); + typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); + difference_type m (it1e1_rend - it1e1); + while (-- m >= 0) + e2 (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; + } } } } @@ -2272,13 +2391,19 @@ namespace boost { namespace numeric { namespace ublas { size_type size1 = e2.size1 (); size_type size2 = e2.size2 (); for (difference_type n = size1 - 1; n >= 0; -- n) { +#ifndef BOOST_UBLAS_SINGULAR_CHECK BOOST_UBLAS_CHECK (e1 () (n, n) != value_type (), singular ()); +#else + if (e1 () (n, n) == value_type ()) + singular.raise (); +#endif for (difference_type l = size2 - 1; l >= 0; -- l) { value_type t = e2 (n, l) /= e1 () (n, n); - typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); - typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); - while (it1e1 != it1e1_rend) { - e2 (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; + if (t != value_type ()) { + typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); + typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); + while (it1e1 != it1e1_rend) + e2 (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; } } } @@ -2297,7 +2422,7 @@ namespace boost { namespace numeric { namespace ublas { void inplace_solve (const matrix_expression &e1, matrix_expression &e2, C) { - inplace_solve (e1, e2, C (), matrix_tag ()); + inplace_solve (e1, e2 (), C (), matrix_tag ()); } template BOOST_UBLAS_INLINE diff --git a/include/boost/numeric/ublas/vector_assign.hpp b/include/boost/numeric/ublas/vector_assign.hpp index 15630efc..76acd599 100644 --- a/include/boost/numeric/ublas/vector_assign.hpp +++ b/include/boost/numeric/ublas/vector_assign.hpp @@ -386,6 +386,8 @@ namespace boost { namespace numeric { namespace ublas { restart (v, index, it, it_end); // The proxies could reference the same container. restart (e, index, ite, ite_end); +#else + ++ ite; #endif } } @@ -489,6 +491,8 @@ namespace boost { namespace numeric { namespace ublas { restart (v, index, it, it_end); // The proxies could reference the same container. restart (e, index, ite, ite_end); +#else + ++ it; #endif } else if (compare > 0) { #ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES @@ -499,6 +503,8 @@ namespace boost { namespace numeric { namespace ublas { restart (e, index, ite, ite_end); // The proxies could reference the same container. restart (v, index, it, it_end); +#else + ++ ite; #endif } } diff --git a/test3/test31.cpp b/test3/test31.cpp index 09f96183..3e67879f 100644 --- a/test3/test31.cpp +++ b/test3/test31.cpp @@ -67,6 +67,7 @@ struct test_my_vector { // Binary vector operations resulting in a vector initialize_vector (v1); initialize_vector (v2); + initialize_vector (v3); v3 = v1 + v2; std::cout << "v1 + v2 = " << v3 << std::endl; diff --git a/test3/test33.cpp b/test3/test33.cpp index fb52ee89..8e5c383e 100644 --- a/test3/test33.cpp +++ b/test3/test33.cpp @@ -63,6 +63,7 @@ struct test_my_matrix { // Binary matrix operations resulting in a matrix initialize_matrix (m1); initialize_matrix (m2); + initialize_matrix (m3); m3 = m1 + m2; std::cout << "m1 + m2 = " << m3 << std::endl; m3 = m1 - m2;